authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-08-07 19:01:36 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-08-07 19:01:36 -07:00
logea85af3e59831ccb105fdc36dc32d8c55d2aa0a6
tree61f094866c3333211e1b48f772d7cb5e05aa21e5
parentf21d52640b16b20aab891ee4e6ae5fb6bd32b9b8

implement `#ifnot`


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

src/lib.zig+9
......@@ -108,6 +108,15 @@ fn do(writer: anytype, comptime value: astgen.Value, data: anytype, ctx: anytype
108108 }
109109 }
110110 },
111 .ifnot => {
112 comptime assertEqual(v.args.len, 1);
113 const x = comptime search(data, v.args[0]);
114 if (!x) {
115 inline for (v.body) |val| {
116 try do(writer, val, data, ctx, indent, flag1);
117 }
118 }
119 },
111120 else => @compileError("pek: block: TODO " ++ @tagName(v.name)),
112121 }
113122 },
src/main.zig+4
......@@ -27,6 +27,10 @@ const example_document =
2727 \\ {#if am_i_a_girl}
2828 \\ p("#1")
2929 \\ /if/
30 \\
31 \\ {#ifnot is_it_my_birthday}
32 \\ p("#2")
33 \\ /ifnot/
3034 \\ )
3135 \\)
3236;
test.html+1
......@@ -23,5 +23,6 @@
2323 </ul>
2424 <p>Spooky text: &LT;strong&GT;I better not be in bold&period;&LT;&sol;strong&GT;</p>
2525 <p>#1</p>
26 <p>#2</p>
2627 </body>
2728</html>