Commit Graph

37 Commits

Author SHA1 Message Date
4f1dcf3640 chore: bump version to 0.1.10 2026-01-23 12:04:03 +05:30
c7fff05c1a chore: bump version to 0.1.9 2026-01-23 12:02:15 +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
a5192e9323 chore: bump version to 0.1.8 2026-01-23 11:52:45 +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
286bf0018f fix: scope mixin variables to avoid redefinition errors on multiple calls 2026-01-22 23:37:28 +05:30
e189abf30f fix: build template bug for same field names 2026-01-22 23:36:42 +05:30
c0bbee089f chore: bump version to 0.1.4 v0.1.4 2026-01-22 23:23:41 +05:30
66981d6908 fix: build template tag with json data issue. 2026-01-22 23:19:39 +05:30
70ba7af27d fix: issue with extends layouts 2026-01-22 23:08:53 +05:30
d53ff24931 fix: template fn name fix for numeric named templates like 404.pug 2026-01-22 22:48:22 +05:30
752b64d0a9 Update CLAUDE.md 2026-01-22 21:28:25 +05:30
ca573f3166 Replace deprecated ArrayListUnmanaged with ArrayList
std.ArrayListUnmanaged is now std.ArrayList in Zig 0.15.
The old managed ArrayList is deprecated as std.array_list.Managed.
2026-01-22 12:45:49 +05:30
0f2f19f9b1 Fix strVal to handle pointer-to-array types correctly
- For pointer-to-array (*[N]u8), explicitly slice using @ptrCast
- Prevents returning dangling pointer to stack memory
2026-01-22 12:39:02 +05:30
654b45ee10 Compiled temapltes.
Benchmark cleanup
2026-01-22 11:10:47 +05:30
714db30a8c Add documentation and interpreted benchmark
- Add docs/syntax.md: complete template syntax reference
- Add docs/api.md: detailed API documentation
- Add src/benchmarks/bench_interpreted.zig: runtime benchmark
- Update build.zig: add bench-interpreted step
- Update README.md: simplified with docs links and benchmark table
2026-01-22 11:08:52 +05:30
510dcfbb03 bench data 2026-01-21 23:41:36 +05:30
5841ec38d8 Update README: clarify GitHub as mirror, prefer for dependencies 2026-01-20 18:08:42 +05:30
e2a1271425 v0.1.3: Add scoped warnings for skipped errors
- Add scoped logger (pugz/runtime) for better log filtering
- Add warnings when mixin not found
- Add warnings for mixin attribute failures
- Add warnings for mixin directory/file lookup failures
- Add warnings for mixin parse/tokenize failures
- Use 'action first, then reason' pattern in all log messages
v0.1.3
2026-01-19 19:31:39 +05:30
a498eea0bc v0.1.2: Bump version v0.1.2 2026-01-19 19:20:33 +05:30
c172009799 v0.1.1: Add warning log when mixin is not found 2026-01-19 19:19:28 +05:30
8ff473839c Bump version to 0.1.0 v0.1.0 2026-01-19 19:11:36 +05:30
7d038df855 Fix panic when mixin not found with relative mixins_dir path
The loadMixinFromDir function used openDirAbsolute which requires an
absolute path, but ViewEngine passes a relative path for mixins_dir.
This caused a panic when a mixin call couldn't find the mixin in the
current template.

Fix: Check if mixins_dir is absolute and use the appropriate method:
- std.fs.openDirAbsolute() for absolute paths
- std.fs.cwd().openDir() for relative paths
2026-01-19 19:01:50 +05:30
c73fb2ed03 Fix memory leak in demo, document arena allocator usage 2026-01-19 12:11:45 +05:30
d48bc3dedd Fix installation instructions with correct git server URL 2026-01-18 19:58:22 +05:30
fe62677a93 Rename test-bench to bench-2, update README with benchmark docs 2026-01-18 00:51:31 +05:30
0bccce8bf9 Add configurable max_file_size option
- Default 5 MB for template files
- Configurable via ViewEngine.init options
2026-01-18 00:05:16 +05:30
458de03c02 Add README and simplify ViewEngine API
- ViewEngine.init() no longer requires allocator
- render() and renderTpl() accept allocator parameter
- Remove deinit() - no resources to clean up
- Remove unused parse/renderDoc methods
- Add memory management guidance to runtime.zig
- Clean up unused imports and options
2026-01-18 00:05:16 +05:30
1fff91d7d9 Add string concatenation in attributes, lazy mixin loading, and benchmarks
Features:
- Fix string concatenation in attribute values (e.g., class="btn btn-" + type)
- Lexer now properly captures full expressions with operators
- Runtime evaluates expressions for class attributes

ViewEngine improvements:
- Change mixin loading from eager to lazy (on-demand)
- Mixins are now loaded from mixins directory only when first called
- Template-defined mixins take precedence over directory mixins

Benchmarks:
- Add src/benchmark.zig with three template complexity levels
- Simple: ~150k renders/sec, 6KB memory
- Medium: ~70k renders/sec, 45KB memory
- Complex: ~32k renders/sec, 94KB memory
- Memory leak detection confirms no leaks

Documentation:
- Update CLAUDE.md with lazy mixin loading details
- Document mixin resolution order
2026-01-18 00:05:16 +05:30
05bbad64a4 Fix expression concatenation in attribute values
- Lexer now emits a single token for the entire expression (e.g., "btn btn-" + type)
- Runtime evaluateExpression now handles + operator for string concatenation
- Added findConcatOperator to safely find operators outside quotes/brackets
2026-01-18 00:05:16 +05:30
8878b630cb Fix infinite loop in lexer when parsing attribute expressions with operators
The lexer would hang when encountering operators like + in attribute values
(e.g., class="btn btn-" + type). Added scanAttrValuePart to handle
expression continuation with operators (+, -, *, /).

Also cleaned up debug prints from view_engine.zig and demo/main.zig.
2026-01-18 00:05:16 +05:30
4538b17f0a Add ViewEngine for easy server integration
- ViewEngine manages views directory with path resolution
- Auto-loads mixins from views/mixins/ directory
- Simplifies template paths (relative to views dir, auto-adds extension)
- Updated example app to use ViewEngine
- Added example mixins (buttons.pug, cards.pug)
- Updated CLAUDE.md with ViewEngine documentation
2026-01-18 00:05:16 +05:30
a65f01fdd0 Remove main.zig CLI executable
Library-only project - examples are in src/examples/
2026-01-18 00:05:16 +05:30
6ab3f14897 Initial commit: Pugz - Pug-like HTML template engine in Zig
Features:
- Lexer with indentation tracking and raw text block support
- Parser producing AST from token stream
- Runtime with variable interpolation, conditionals, loops
- Mixin support (params, defaults, rest args, block content, attributes)
- Template inheritance (extends/block/append/prepend)
- Plain text (piped, dot blocks, literal HTML)
- Tag interpolation (#[tag text])
- Block expansion with colon
- Self-closing tags (void elements + explicit /)
- Case/when statements
- Comments (rendered and silent)

All 113 tests passing.
2026-01-18 00:05:16 +05:30
Ankit Patial
71f4ec4ffc Initial commit 2026-01-17 20:07:55 +05:30