diff --git a/src/template/lib.zig b/src/template/lib.zig index 1c33d22..029d921 100644 --- a/src/template/lib.zig +++ b/src/template/lib.zig @@ -184,6 +184,7 @@ fn evaluateExpression( } fn AddCapture(comptime Root: type, comptime name: []const u8, comptime Val: type) type { + if (std.mem.eql(u8, name, "_")) return Root; var fields = std.meta.fields(Root) ++ [_]std.builtin.Type.StructField{.{ .name = name, .field_type = Val, @@ -201,6 +202,7 @@ fn AddCapture(comptime Root: type, comptime name: []const u8, comptime Val: type } fn addCapture(root: anytype, comptime name: []const u8, val: anytype) AddCapture(@TypeOf(root), name, @TypeOf(val)) { + if (comptime std.mem.eql(u8, name, "_")) return root; var result = std.mem.zeroInit(AddCapture(@TypeOf(root), name, @TypeOf(val)), root); @field(result, name) = val; return result; diff --git a/src/template/test.tmp.html b/src/template/test.tmp.html index ef41e35..f6e12b3 100644 --- a/src/template/test.tmp.html +++ b/src/template/test.tmp.html @@ -24,6 +24,7 @@ {#if .maybe_foo |$v|}{$v}{#else}null{/if} {#if .maybe_bar |$v|}{$v}{#else}null{/if} + {#if .maybe_foo |$_|}abcd{#else}null{/if}