feat: add template inheritance (extends/block) support

- ViewEngine now supports extends and named blocks
- Each route gets exclusive cached AST (no shared parent layouts)
- Fix iteration over struct arrays in each loops
- Add demo app with full e-commerce layout using extends
- Serve static files from public folder
- Bump version to 0.3.0
This commit is contained in:
2026-01-25 15:23:57 +05:30
parent 776f8a68f5
commit 1b2da224be
52 changed files with 2962 additions and 728 deletions

View File

@@ -0,0 +1,752 @@
/* Pugz Store - Clean Modern CSS */
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
:root {
--primary: #3b82f6;
--primary-dark: #2563eb;
--text: #1f2937;
--text-muted: #6b7280;
--bg: #ffffff;
--bg-alt: #f9fafb;
--border: #e5e7eb;
--success: #10b981;
--radius: 8px;
}
body {
font-family: system-ui, -apple-system, sans-serif;
line-height: 1.6;
color: var(--text);
background: var(--bg);
}
a {
color: var(--primary);
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
/* Layout */
.container {
max-width: 1100px;
margin: 0 auto;
padding: 0 20px;
}
/* Header */
.header {
background: var(--bg);
border-bottom: 1px solid var(--border);
position: sticky;
top: 0;
z-index: 100;
}
.header-content {
display: flex;
align-items: center;
justify-content: space-between;
padding: 16px 0;
}
.logo {
font-size: 1.5rem;
font-weight: 700;
color: var(--primary);
}
.logo:hover {
text-decoration: none;
}
.nav {
display: flex;
gap: 24px;
}
.nav-link {
color: var(--text-muted);
font-weight: 500;
}
.nav-link:hover {
color: var(--primary);
text-decoration: none;
}
.header-actions {
display: flex;
align-items: center;
}
.cart-link {
color: var(--text);
font-weight: 500;
}
/* Footer */
.footer {
background: var(--text);
color: white;
padding: 40px 0;
margin-top: 60px;
}
.footer-content {
text-align: center;
}
.footer-content p {
color: #9ca3af;
}
/* Buttons */
.btn {
display: inline-block;
padding: 10px 20px;
font-size: 14px;
font-weight: 500;
border-radius: var(--radius);
border: none;
cursor: pointer;
text-align: center;
transition: all 0.2s;
}
.btn:hover {
text-decoration: none;
}
.btn-primary {
background: var(--primary);
color: white;
}
.btn-primary:hover {
background: var(--primary-dark);
}
.btn-outline {
background: transparent;
border: 1px solid var(--border);
color: var(--text);
}
.btn-outline:hover {
border-color: var(--primary);
color: var(--primary);
}
.btn-sm {
padding: 6px 12px;
font-size: 13px;
}
.btn-block {
display: block;
width: 100%;
}
/* Hero Section */
.hero {
background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
color: white;
padding: 80px 0;
text-align: center;
}
.hero h1 {
font-size: 2.5rem;
margin-bottom: 16px;
}
.hero p {
font-size: 1.1rem;
opacity: 0.9;
margin-bottom: 32px;
}
.hero-actions {
display: flex;
gap: 12px;
justify-content: center;
}
.hero .btn-outline {
border-color: rgba(255, 255, 255, 0.4);
color: white;
}
.hero .btn-outline:hover {
border-color: white;
background: rgba(255, 255, 255, 0.1);
}
/* Sections */
.section {
padding: 60px 0;
}
.section-alt {
background: var(--bg-alt);
}
.section h2 {
font-size: 1.75rem;
margin-bottom: 32px;
}
.page-header {
background: var(--bg-alt);
padding: 40px 0;
border-bottom: 1px solid var(--border);
}
.page-header h1 {
font-size: 2rem;
margin-bottom: 8px;
}
.page-header p {
color: var(--text-muted);
}
/* Feature Grid */
.feature-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
gap: 24px;
}
.feature-card {
background: var(--bg);
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 24px;
}
.feature-card h3 {
font-size: 1.1rem;
margin-bottom: 12px;
}
.feature-card p {
color: var(--text-muted);
font-size: 14px;
}
.feature-card ul {
margin: 0;
padding-left: 20px;
color: var(--text-muted);
font-size: 14px;
}
.feature-card li {
margin-bottom: 4px;
}
/* Category Grid */
.category-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 24px;
}
.category-card {
background: var(--bg);
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 32px 24px;
text-align: center;
transition: all 0.2s;
}
.category-card:hover {
border-color: var(--primary);
text-decoration: none;
transform: translateY(-2px);
}
.category-icon {
width: 60px;
height: 60px;
margin: 0 auto 16px;
background: var(--bg-alt);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 1.5rem;
font-weight: 600;
color: var(--primary);
}
.category-card h3 {
font-size: 1rem;
color: var(--text);
margin-bottom: 4px;
}
.category-card span {
font-size: 14px;
color: var(--text-muted);
}
/* Product Grid */
.product-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
gap: 24px;
margin-bottom: 40px;
}
.product-card {
background: var(--bg);
border: 1px solid var(--border);
border-radius: var(--radius);
overflow: hidden;
transition: all 0.2s;
}
.product-card:hover {
border-color: var(--primary);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
.product-image {
position: relative;
height: 180px;
background: var(--bg-alt);
}
.product-badge {
position: absolute;
top: 12px;
left: 12px;
background: #ef4444;
color: white;
padding: 4px 10px;
font-size: 12px;
font-weight: 600;
border-radius: 4px;
}
.product-info {
padding: 16px;
}
.product-category {
font-size: 12px;
color: var(--text-muted);
text-transform: uppercase;
letter-spacing: 0.05em;
}
.product-name {
font-size: 1rem;
margin: 6px 0 12px;
}
.product-price {
font-size: 1.1rem;
font-weight: 600;
color: var(--text);
margin-bottom: 12px;
}
/* Products Toolbar */
.products-toolbar {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 24px;
}
.results-count {
color: var(--text-muted);
}
.sort-options {
display: flex;
align-items: center;
gap: 8px;
}
.sort-options label {
color: var(--text-muted);
font-size: 14px;
}
.sort-options select {
padding: 8px 12px;
border: 1px solid var(--border);
border-radius: var(--radius);
font-size: 14px;
}
/* Pagination */
.pagination {
display: flex;
justify-content: center;
gap: 8px;
}
.page-link {
padding: 8px 14px;
border: 1px solid var(--border);
border-radius: var(--radius);
color: var(--text-muted);
font-size: 14px;
}
.page-link:hover {
border-color: var(--primary);
color: var(--primary);
text-decoration: none;
}
.page-link.active {
background: var(--primary);
border-color: var(--primary);
color: white;
}
/* Cart */
.cart-layout {
display: grid;
grid-template-columns: 1fr 340px;
gap: 32px;
}
.cart-items {
background: var(--bg);
border: 1px solid var(--border);
border-radius: var(--radius);
}
.cart-item {
display: grid;
grid-template-columns: 1fr auto auto auto;
gap: 20px;
padding: 20px;
align-items: center;
border-bottom: 1px solid var(--border);
}
.cart-item:last-child {
border-bottom: none;
}
.cart-item-info h3 {
font-size: 1rem;
margin-bottom: 4px;
}
.cart-item-price {
color: var(--text-muted);
font-size: 14px;
}
.cart-item-qty {
display: flex;
align-items: center;
}
.qty-btn {
width: 32px;
height: 32px;
border: 1px solid var(--border);
background: var(--bg);
cursor: pointer;
font-size: 16px;
}
.qty-input {
width: 48px;
height: 32px;
border: 1px solid var(--border);
border-left: none;
border-right: none;
text-align: center;
font-size: 14px;
}
.cart-item-total {
font-weight: 600;
min-width: 80px;
text-align: right;
}
.cart-item-remove {
width: 32px;
height: 32px;
border: none;
background: none;
color: var(--text-muted);
cursor: pointer;
font-size: 18px;
}
.cart-item-remove:hover {
color: #ef4444;
}
.cart-actions {
padding: 20px;
border-top: 1px solid var(--border);
}
.cart-summary {
background: var(--bg);
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 24px;
height: fit-content;
}
.cart-summary h3 {
font-size: 1.1rem;
margin-bottom: 20px;
padding-bottom: 16px;
border-bottom: 1px solid var(--border);
}
.summary-row {
display: flex;
justify-content: space-between;
margin-bottom: 12px;
font-size: 14px;
}
.summary-total {
font-size: 1.1rem;
font-weight: 600;
margin-top: 16px;
padding-top: 16px;
border-top: 1px solid var(--border);
}
/* About Page */
.about-grid {
display: grid;
grid-template-columns: 2fr 1fr;
gap: 40px;
}
.about-main h2 {
margin-bottom: 16px;
}
.about-main h3 {
margin: 24px 0 12px;
font-size: 1.1rem;
}
.about-main p {
color: var(--text-muted);
margin-bottom: 12px;
}
.feature-list {
list-style: none;
padding: 0;
}
.feature-list li {
padding: 10px 0;
border-bottom: 1px solid var(--border);
font-size: 14px;
}
.about-sidebar {
display: flex;
flex-direction: column;
gap: 20px;
}
.info-card {
background: var(--bg-alt);
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 20px;
}
.info-card h3 {
font-size: 1rem;
margin-bottom: 12px;
}
.info-card ul {
margin: 0;
padding-left: 18px;
font-size: 14px;
color: var(--text-muted);
}
.info-card li {
margin-bottom: 6px;
}
/* Product Detail */
.product-detail {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 48px;
}
.product-detail-image {
background: var(--bg-alt);
border-radius: var(--radius);
aspect-ratio: 1;
}
.product-image-placeholder {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
color: var(--text-muted);
}
.product-detail-info h1 {
font-size: 2rem;
margin: 8px 0 16px;
}
.product-price-large {
font-size: 1.75rem;
font-weight: 600;
color: var(--primary);
margin-bottom: 16px;
}
.product-description {
color: var(--text-muted);
margin-bottom: 24px;
line-height: 1.7;
}
.product-actions {
display: flex;
gap: 16px;
align-items: center;
margin-bottom: 24px;
}
.quantity-selector {
display: flex;
align-items: center;
gap: 8px;
}
.quantity-selector label {
font-weight: 500;
}
.product-meta {
padding-top: 24px;
border-top: 1px solid var(--border);
}
.product-meta p {
color: var(--text-muted);
font-size: 14px;
margin-bottom: 8px;
}
.breadcrumb {
font-size: 14px;
color: var(--text-muted);
}
.breadcrumb a {
color: var(--text-muted);
}
.breadcrumb a:hover {
color: var(--primary);
}
.breadcrumb span {
margin: 0 8px;
}
/* Error Page */
.error-page {
padding: 100px 0;
text-align: center;
}
.error-code {
font-size: 8rem;
font-weight: 700;
color: var(--border);
line-height: 1;
}
.error-content h2 {
margin: 16px 0 8px;
}
.error-content p {
color: var(--text-muted);
margin-bottom: 32px;
}
.error-actions {
display: flex;
gap: 12px;
justify-content: center;
}
/* Utility Classes */
.text-success {
color: var(--success);
}
.text-muted {
color: var(--text-muted);
}
/* Responsive */
@media (max-width: 768px) {
.header-content {
flex-wrap: wrap;
gap: 16px;
}
.nav {
order: 3;
width: 100%;
justify-content: center;
}
.hero h1 {
font-size: 2rem;
}
.hero-actions {
flex-direction: column;
align-items: center;
}
.cart-layout,
.about-grid {
grid-template-columns: 1fr;
}
.cart-item {
grid-template-columns: 1fr;
gap: 12px;
}
}