| ... | ... | @@ -716,6 +716,31 @@ test { |
| 716 | 716 | \\ |
| 717 | 717 | ); |
| 718 | 718 | } |
| 719 | test { |
| 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 | } |
| 719 | 744 | |
| 720 | 745 | // replacement with custom serializer |
| 721 | 746 | test { |