From ef27bb5c2197536506d6f3b033548d57c05dd2d8 Mon Sep 17 00:00:00 2001 From: jaina heartles Date: Thu, 8 Dec 2022 02:58:18 -0800 Subject: [PATCH] Let . refer to entire args struct --- src/template/lib.zig | 3 ++- src/template/test.tmp.html | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/template/lib.zig b/src/template/lib.zig index 029d921..413cc53 100644 --- a/src/template/lib.zig +++ b/src/template/lib.zig @@ -17,6 +17,7 @@ pub fn main() !void { .quxx = true, .maybe_foo = @as(?[]const u8, "foo"), .maybe_bar = @as(?[]const u8, null), + .x = "y", }, .{ .context_foo = "foo", @@ -658,7 +659,7 @@ fn parseDeref(comptime tokens: ControlTokenIter) ParseResult(ControlTokenIter, [ if (wants != .period) @compileError("Unexpected token \".\""); wants = .text; }, - else => if (wants == .period) return .{ + else => if (wants == .period or fields.len == 0) return .{ .new_iter = iter, .item = fields, } else @compileError("Unexpected token"), diff --git a/src/template/test.tmp.html b/src/template/test.tmp.html index f6e12b3..aa0100a 100644 --- a/src/template/test.tmp.html +++ b/src/template/test.tmp.html @@ -27,6 +27,7 @@ {#if .maybe_foo |$_|}abcd{#else}null{/if} + {@context_foo}