Skip to content

Commit 326ea37

Browse files
committed
fix rendering of scripted self-closing xml elements
1 parent d4d81e1 commit 326ea37

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

src/template.zig

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -907,11 +907,19 @@ pub fn SuperTemplate(comptime ScriptyVM: type) type {
907907
}
908908

909909
if (elem.kind.isElement() and !elem.kind.isVoid()) {
910-
// Print up to the close tag
911-
const end = elem.close.end;
912-
const up_to_attr = tpl.src[tpl.print_cursor..end];
913-
writer.writeAll(up_to_attr) catch return error.OutIO;
914-
tpl.print_cursor = end;
910+
if (elem.self_closing) {
911+
// Synthesize a closing tag
912+
writer.print("</{s}>", .{
913+
elem.open.getName(tpl.src, tpl.html.language).slice(tpl.src),
914+
}) catch return error.OutIO;
915+
916+
} else {
917+
// Print up to the close tag
918+
const end = elem.close.end;
919+
const up_to_end = tpl.src[tpl.print_cursor..end];
920+
writer.writeAll(up_to_end) catch return error.OutIO;
921+
tpl.print_cursor = end;
922+
}
915923
}
916924
_ = tpl.cursor.next();
917925
},

0 commit comments

Comments
 (0)