update: add verbatim
This commit is contained in:
parent
0192ad0b64
commit
b7550e9b01
3 changed files with 89 additions and 1 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue