[ADD] utils: add loadTemplates function

This commit is contained in:
Géry Debongnie
2019-04-18 22:42:37 +02:00
parent 85418043f4
commit ae263730d9
+10
View File
@@ -163,3 +163,13 @@ export function unpatch(C: any, patchName: string) {
}
}
}
export async function loadTemplates(url: string): Promise<string> {
const result = await fetch(url);
if (!result.ok) {
throw new Error("Error while fetching xml templates");
}
let templates = await result.text();
templates = templates.replace(/<!--[\s\S]*?-->/g, "");
return templates;
}