add loadtemplates method to qweb

This commit is contained in:
Géry Debongnie
2019-02-02 11:18:31 +01:00
parent 42e932ef0b
commit bfe83c5b70
2 changed files with 48 additions and 17 deletions
+16
View File
@@ -679,3 +679,19 @@ describe("t-ref", () => {
expect(refs.myspan.tagName).toBe("SPAN");
});
});
describe("loading templates", () => {
test("can load a few templates from a xml string", () => {
const data = `
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-name="items"><li>ok</li><li>foo</li></t>
<ul t-name="main"><t t-call="items"/></ul>
</templates>`;
qweb.loadTemplates(data);
const result = renderToString(qweb, "main");
expect(result).toBe("<ul><li>ok</li><li>foo</li></ul>");
});
});