about summary refs log tree commit diff
path: root/src/main.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/main.zig b/src/main.zig
index 785a182..6884097 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -148,18 +148,19 @@ fn inject(allocator: std.mem.Allocator, w: std.io.AnyWriter, srcpath: []const u8
         buf_reader.buf.len,
     ) catch {
         @panic("Failed to read from stream");
-    }) |chunk| {
+    }) |chunk_| {
         defer _ = arena.reset(.free_all);
 
-        if (std.mem.indexOfPosLinear(u8, chunk, 0, "{")) |start| {
-            if (std.mem.indexOfPosLinear(u8, chunk, start + 1, "}")) |end| {
-                try out_stream.writeAll(chunk[0..start]);
-                template(allocator, out_stream.any(), chunk[start + 1 .. end]) catch
-                    @panic("Failed to resolve template");
-                try out_stream.writeAll(chunk[end + 1 ..]);
-                try out_stream.writeByte('\n');
-                continue;
-            }
+        var chunk = chunk_;
+        templating: while (true) {
+            if (std.mem.indexOfPosLinear(u8, chunk, 0, "{")) |start| {
+                if (std.mem.indexOfPosLinear(u8, chunk, start + 1, "}")) |end| {
+                    try out_stream.writeAll(chunk[0..start]);
+                    template(allocator, out_stream.any(), chunk[start + 1 .. end]) catch
+                        @panic("Failed to resolve template");
+                    chunk = chunk[end + 1 ..];
+                } else break :templating;
+            } else break :templating;
         }
 
         try out_stream.writeAll(chunk);