update: debugNodes function to display nodes content
This commit is contained in:
parent
44fb897a41
commit
7c53a272a7
1 changed files with 29 additions and 0 deletions
|
|
@ -943,6 +943,35 @@ pub const Parser = struct {
|
|||
return .{ .template = template };
|
||||
}
|
||||
|
||||
pub fn debugNodes(self: Parser, data: struct {
|
||||
nodes: []Node,
|
||||
name: ?[]const u8 = null,
|
||||
}) void {
|
||||
_ = self;
|
||||
var prefix: []const u8 = "";
|
||||
|
||||
if (data.name) |name| {
|
||||
prefix = " - ";
|
||||
std.debug.print("{s}:\n", .{name});
|
||||
}
|
||||
|
||||
for (data.nodes) |node| {
|
||||
if (node.type == .tag) {
|
||||
if (node.type == .tag and node.tag.?.kind == .block) {
|
||||
std.debug.print("{s}tag: {any}, name: {s}\n", .{ prefix, node.tag.?.kind, node.tag.?.body.block.name });
|
||||
} else {
|
||||
std.debug.print("{s}tag: {any}\n", .{ prefix, node.tag.?.kind });
|
||||
}
|
||||
}
|
||||
if (node.type == .text) {
|
||||
std.debug.print("{s}text: {s}\n", .{ prefix, node.text.?.content });
|
||||
}
|
||||
if (node.type == .variable) {
|
||||
std.debug.print("{s}variable: {s}\n", .{ prefix, node.variable.?.expr });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn advance(self: *Parser, n: usize) void {
|
||||
self.pos += n;
|
||||
if (self.pos > self.template.len) self.pos = self.template.len;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue