[IMP] component tags: allow injecting values in xml tag string

With this commit, we can now do this:

      const SUBTEMPLATE = xml`<span><t t-esc="state.n"/></span>`
      class Parent extends Widget {
          static template = xml`<div><t t-call="${SUBTEMPLATE}"/></div>`
          state = {n: 42};
      }
This commit is contained in:
Géry Debongnie
2019-09-21 23:05:44 +02:00
parent cc82b3ffcd
commit 78a4550ebb
3 changed files with 34 additions and 2 deletions
+13
View File
@@ -2310,6 +2310,19 @@ describe("random stuff/miscellaneous", () => {
"C:patched"
]);
});
test("can inject values in tagged templates", async () => {
const SUBTEMPLATE = xml`<span><t t-esc="state.n"/></span>`
class Parent extends Widget {
static template = xml`<div><t t-call="${SUBTEMPLATE}"/></div>`
state = {n: 42};
}
const widget = new Parent(env);
await widget.mount(fixture);
expect(env.qweb.templates[Parent.template].fn.toString()).toMatchSnapshot();
expect(fixture.innerHTML).toBe('<div><span>42</span></div>')
});
});
describe("async rendering", () => {