authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-08-07 19:02:03 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-08-07 19:02:03 -07:00
logaa52db981ada69dcebc9fec54956fe2cd17e58a4
treedeef4956522230719c9e9597fda00a42c5644108
parentea85af3e59831ccb105fdc36dc32d8c55d2aa0a6

implement `#ifequal`


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

src/lib.zig+10
......@@ -117,6 +117,16 @@ fn do(writer: anytype, comptime value: astgen.Value, data: anytype, ctx: anytype
117117 }
118118 }
119119 },
120 .ifequal => {
121 comptime assertEqual(v.args.len, 2);
122 const x = comptime search(data, v.args[0]);
123 const y = comptime search(data, v.args[1]);
124 if (x == y) {
125 inline for (v.body) |val| {
126 try do(writer, val, data, ctx, indent, flag1);
127 }
128 }
129 },
120130 else => @compileError("pek: block: TODO " ++ @tagName(v.name)),
121131 }
122132 },
src/main.zig+4
......@@ -31,6 +31,10 @@ const example_document =
3131 \\ {#ifnot is_it_my_birthday}
3232 \\ p("#2")
3333 \\ /ifnot/
34 \\
35 \\ {#ifequal top_cities.len best_rating}
36 \\ p("#3")
37 \\ /ifequal/
3438 \\ )
3539 \\)
3640;
test.html+1
......@@ -24,5 +24,6 @@
2424 <p>Spooky text: &LT;strong&GT;I better not be in bold&period;&LT;&sol;strong&GT;</p>
2525 <p>#1</p>
2626 <p>#2</p>
27 <p>#3</p>
2728 </body>
2829</html>