authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-02-15 17:11:52 -08:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-02-15 17:11:52 -08:00
logc767c52ebf1d9ef042e3f17febebbee3582a9339
tree3e7eb1d0e5a687f38b2a9046dbe26a069e27de1e
parent73871a617d80b4750fd51f903bf1cf0a29ee8f4c

support values passed in by pointer


2 files changed, 26 insertions(+), 0 deletions(-)

src/lib.zig+1
......@@ -375,6 +375,7 @@ fn Field(comptime T: type, comptime field_name: string) type {
375375 }
376376 switch (@typeInfo(T)) {
377377 .optional => |info| return Field(info.child, field_name),
378 .pointer => |info| return Field(info.child, field_name),
378379 else => {},
379380 }
380381 for (std.meta.fields(T)) |fld| {
test.zig+25
......@@ -716,6 +716,31 @@ test {
716716 \\
717717 );
718718}
719test {
720 const alloc = std.testing.allocator;
721 var builder = std.ArrayList(u8).init(alloc);
722 defer builder.deinit();
723 const S = struct { x: []const u8, y: u32 };
724 const text: S = .{ .x = "dynamic", .y = 47 };
725 const doc = comptime pek.parse(
726 \\body(
727 \\ p("This text for this link is "a[href="https://github.com/nektro/zig-pek"]({text.x})".")
728 \\)
729 );
730 try pek.compileInner(
731 alloc,
732 builder.writer(),
733 doc,
734 .{ .Ctx = @This(), .indent = 0, .doindent = true, .doindent2 = true },
735 .{ .text = &text },
736 );
737 try expect(builder.items).toEqualString(
738 \\<body>
739 \\ <p>This text for this link is <a href="https://github.com/nektro/zig-pek">dynamic</a>.</p>
740 \\</body>
741 \\
742 );
743}
719744
720745// replacement with custom serializer
721746test {