update: add verbatim

This commit is contained in:
Lucas F. 2026-01-03 18:38:25 -03:00
parent 0192ad0b64
commit b7550e9b01
3 changed files with 89 additions and 1 deletions

View file

@ -471,3 +471,32 @@ test "parse spaceless aninhado" {
}
try testing.expectEqual(@as(usize, 3), sl.body.len);
}
test "parse verbatim simples" {
const allocator = testing.allocator;
const template = "Texto {% verbatim %}{{ variável }}{% endblock %}{% endverbatim %} Texto";
const nodes = try parser.parse(allocator, template);
defer {
for (nodes) |node| node.deinit(allocator);
allocator.free(nodes);
}
try testing.expectEqual(@as(usize, 3), nodes.len);
try testing.expectEqualStrings("Texto ", nodes[0].text.?.content);
try testing.expectEqualStrings("{{ variável }}{% endblock %}", nodes[1].text.?.content);
try testing.expectEqualStrings(" Texto", nodes[2].text.?.content);
}
test "parse verbatim aninhado" {
const allocator = testing.allocator;
const template = "{% verbatim %}Outer {% verbatim %}Inner{% endverbatim %} Outer{% endverbatim %}";
const nodes = try parser.parse(allocator, template);
defer {
for (nodes) |node| node.deinit(allocator);
allocator.free(nodes);
}
try testing.expectEqual(@as(usize, 1), nodes.len);
try testing.expect(nodes[0].type == .text);
try testing.expectEqualStrings("Outer {% verbatim %}Inner{% endverbatim %} Outer", nodes[0].text.?.content);
}