authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-08-07 19:01:10 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-08-07 19:01:10 -07:00
logf21d52640b16b20aab891ee4e6ae5fb6bd32b9b8
tree6ec6852a5cead4c374b8f509d1c7a0a7a292f51b
parent606c72eb48ee9678dcb222f3463e6f2acb8e66cd

implement `#if`


3 files changed, 13 insertions(+), 0 deletions(-)

src/lib.zig+9
......@@ -99,6 +99,15 @@ fn do(writer: anytype, comptime value: astgen.Value, data: anytype, ctx: anytype
9999 }
100100 }
101101 },
102 .@"if" => {
103 comptime assertEqual(v.args.len, 1);
104 const x = comptime search(data, v.args[0]);
105 if (x) {
106 inline for (v.body) |val| {
107 try do(writer, val, data, ctx, indent, flag1);
108 }
109 }
110 },
102111 else => @compileError("pek: block: TODO " ++ @tagName(v.name)),
103112 }
104113 },
src/main.zig+3
......@@ -24,6 +24,9 @@ const example_document =
2424 \\ )
2525 \\ p("Spooky text: "{spooky})
2626 \\
27 \\ {#if am_i_a_girl}
28 \\ p("#1")
29 \\ /if/
2730 \\ )
2831 \\)
2932;
test.html+1
......@@ -22,5 +22,6 @@
2222 <li>Phoenix, AZ</li>
2323 </ul>
2424 <p>Spooky text: &LT;strong&GT;I better not be in bold&period;&LT;&sol;strong&GT;</p>
25 <p>#1</p>
2526 </body>
2627</html>