Commit Graph

21 Commits

Author SHA1 Message Date
dd2191829d fix: flush static buffer in conditionals and correct helpers import path
- Flush static buffer at end of each conditional branch (if/else/else-if)
  to ensure content is rendered inside the correct blocks
- Add helpers_path parameter to zig_codegen.generate() for correct
  relative imports in nested directories (e.g., '../helpers.zig')
- Fix build.zig to use correct CLI path (src/tpl_compiler/main.zig)
- Export zig_codegen from root.zig for CLI module usage

Bump version to 0.3.11
2026-01-30 22:59:47 +05:30
5ce319b335 Fix mixin expansion in conditionals and include resolution in extends
- mixin.zig: expandNode and expandNodeWithArgs now recurse into
  node.consequent and node.alternate for Conditional nodes
- view_engine.zig: process includes and collect mixins from child
  template before extracting blocks in processExtends

This fixes mixin calls inside if/else blocks not being rendered
in compiled templates.
2026-01-30 22:24:27 +05:30
036befa23c include, extend file path correction 2026-01-29 19:09:53 +05:30
14128aeeea feat: add @TypeOf type hints for compiled templates
- Add TypeHint node type in parser for //- @TypeOf(field): type syntax
- Support scalar types (f32, i32, bool, etc.) and array/struct types
- Use helpers.appendValue() for non-string typed fields
- Filter out loop variable references from Data struct fields
- Preserve @TypeOf comments during comment stripping

Example usage:
  //- @TypeOf(subtotal): f32
  span $#{subtotal}

  //- @TypeOf(items): []{name: []const u8, price: f32}
  each item in items
    h3 #{item.name}
2026-01-28 22:31:24 +05:30
e2025d7de8 - demo build fix.
- README changes for bench values.
2026-01-28 19:38:59 +05:30
8db2e0df37 Genearte .zig verions of templates to use in production. 2026-01-28 17:01:28 +05:30
90c8f6f2fb - removed cache
- few comptime related changes
2026-01-27 16:04:02 +05:30
aaf6a1af2d fix: add scoped error logging for lexer/parser errors
- Add std.log.scoped(.pugz) to template.zig and view_engine.zig
- Log detailed error info (code, line, column, message) when parsing fails
- Log template path context in ViewEngine on parse errors
- Remove debug print from lexer, use proper scoped logging instead
- Move benchmarks, docs, examples, playground, tests out of src/ to project root
- Update build.zig and documentation paths accordingly
- Bump version to 0.3.1
2026-01-25 17:10:02 +05:30
7bcb79c7bc refactor: move docs and examples to src folder, update README with accurate benchmarks 2026-01-25 15:32:38 +05:30
1b2da224be 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
2026-01-25 15:23:57 +05:30
27c4898706 follow PugJs 2026-01-24 23:53:19 +05:30
621f8def47 fix: add security protections and cleanup failing tests
Security fixes:
- Add path traversal protection in include/extends (rejects '..' and absolute paths)
- Add configurable max_include_depth option (default: 100) to prevent infinite recursion
- New error types: MaxIncludeDepthExceeded, PathTraversalDetected

Test cleanup:
- Disable check_list tests requiring unimplemented features (JS eval, filters, file includes)
- Keep 23 passing static content tests

Bump version to 0.2.2
2026-01-24 14:31:24 +05:30
53f147f5c4 fix: make conditional fields optional using @hasField
Templates can now use 'if error' or similar conditionals without
requiring the caller to always provide those fields in the data struct.
2026-01-23 12:10:48 +05:30
efaaa5565d fix: properly handle mixin call attributes in compiled templates
- Create typed attributes struct for each mixin call with optional fields (class, id, style)
- Use unique variable names (mixin_attrs_N) to avoid shadowing in nested mixin calls
- Track current attributes variable for buildAccessor to resolve attributes.class correctly
- Only suppress unused variable warning when attributes aren't actually accessed
2026-01-23 12:02:04 +05:30
b079bbffff fix: escape quotes in backtick strings and merge duplicate class attributes
- HTML-escape double quotes as " in backtick template literals for valid attribute values
- Merge shorthand classes (.alert) with class attribute values instead of emitting duplicates
- Handle string concatenation expressions in class attributes (e.g., class="btn btn-" + type)
2026-01-23 11:50:18 +05:30
3de712452c fix: support Angular-style attributes and object/array literals in compiled templates
Lexer changes:
- Support quoted attribute names: '(click)'='play()' or "(click)"="play()"
- Support parenthesized attribute names: (click)='play()' (Angular/Vue event bindings)

Build templates changes:
- Object literals for style attribute converted to CSS: {color: 'red'} -> color:red;
- Object literals for other attributes: extract values as space-separated
- Array literals converted to space-separated: ['foo', 'bar'] -> foo bar
2026-01-23 00:06:04 +05:30
e6a6c1d87f fix: avoid variable shadowing in nested mixin calls with same parameter name
When a mixin calls another mixin passing a variable with the same name
as the parameter (e.g., +alert(message) where alert has param message),
skip generating redundant const declaration since the variable is already
in scope.

Also adds missing alert.pug mixin for demo project.
2026-01-22 23:49:01 +05:30
e189abf30f fix: build template bug for same field names 2026-01-22 23:36:42 +05:30
66981d6908 fix: build template tag with json data issue. 2026-01-22 23:19:39 +05:30
d53ff24931 fix: template fn name fix for numeric named templates like 404.pug 2026-01-22 22:48:22 +05:30
654b45ee10 Compiled temapltes.
Benchmark cleanup
2026-01-22 11:10:47 +05:30