[IMP] templates: can load multiple at once and also from XMLDocument

This commit is contained in:
Bruno Boi
2021-11-16 11:39:01 +01:00
committed by Aaron Bohy
parent 03787cfb39
commit db93ef08ff
7 changed files with 184 additions and 59 deletions
+3 -4
View File
@@ -173,11 +173,10 @@ interface ParsingContext {
inPreTag: boolean;
}
export function parse(xml: string): AST {
const template = `<t>${xml}</t>`;
const doc = parseXML(template);
export function parse(xml: string | Node): AST {
const node = xml instanceof Element ? xml : parseXML(`<t>${xml}</t>`).firstChild!;
const ctx = { inPreTag: false };
const ast = parseNode(doc.firstChild!, ctx);
const ast = parseNode(node, ctx);
if (!ast) {
return { type: ASTType.Text, value: "" };
}