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...@@ -108,6 +108,15 @@ fn do(writer: anytype, comptime value: astgen.Value, data: anytype, ctx: anytype
108 }108 }
109 }109 }
110 },110 },
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 },
111 else => @compileError("pek: block: TODO " ++ @tagName(v.name)),120 else => @compileError("pek: block: TODO " ++ @tagName(v.name)),
112 }121 }
113 },122 },
src/main.zig+4
...@@ -27,6 +27,10 @@ const example_document =...@@ -27,6 +27,10 @@ const example_document =
27 \\ {#if am_i_a_girl}27 \\ {#if am_i_a_girl}
28 \\ p("#1")28 \\ p("#1")
29 \\ /if/29 \\ /if/
30 \\
31 \\ {#ifnot is_it_my_birthday}
32 \\ p("#2")
33 \\ /ifnot/
30 \\ )34 \\ )
31 \\)35 \\)
32;36;
test.html+1
...@@ -23,5 +23,6 @@...@@ -23,5 +23,6 @@
23 </ul>23 </ul>
24 <p>Spooky text: &LT;strong&GT;I better not be in bold&period;&LT;&sol;strong&GT;</p>24 <p>Spooky text: &LT;strong&GT;I better not be in bold&period;&LT;&sol;strong&GT;</p>
25 <p>#1</p>25 <p>#1</p>
26 <p>#2</p>
26 </body>27 </body>
27</html>28</html>