diff --git a/src/qweb/base_directives.ts b/src/qweb/base_directives.ts
index aa14bf9a..e737491f 100644
--- a/src/qweb/base_directives.ts
+++ b/src/qweb/base_directives.ts
@@ -267,16 +267,13 @@ QWeb.addDirective({
for (let attr of ["t-if", "t-else", "t-elif", "t-call"]) {
nodeCopy.removeAttribute(attr);
}
- const parentNode = ctx.parentNode;
- ctx.parentNode = "__0";
// this local scope is intended to trap c__0
ctx.addLine(`{`);
ctx.indent();
ctx.addLine("let c__0 = [];");
- qweb._compileNode(nodeCopy, ctx);
+ qweb._compileNode(nodeCopy, ctx.subContext("parentNode", "__0"));
ctx.rootContext.shouldDefineUtils = true;
ctx.addLine("scope[utils.zero] = c__0;");
- ctx.parentNode = parentNode;
ctx.dedent();
ctx.addLine(`}`);
}
diff --git a/tests/qweb/__snapshots__/qweb.test.ts.snap b/tests/qweb/__snapshots__/qweb.test.ts.snap
index 4392f539..8d75f4e3 100644
--- a/tests/qweb/__snapshots__/qweb.test.ts.snap
+++ b/tests/qweb/__snapshots__/qweb.test.ts.snap
@@ -1798,6 +1798,35 @@ exports[`t-call (template calling t-call allowed on a non t node 1`] = `
}"
`;
+exports[`t-call (template calling t-call with body content as root of a template 1`] = `
+"function anonymous(context, extra
+) {
+ // Template name: \\"main\\"
+ let utils = this.constructor.utils;
+ let scope = Object.create(context);
+ let result;
+ let h = this.h;
+ let _origScope3 = scope;
+ scope = Object.create(scope);
+ scope.__access_mode__ = 'ro';
+ {
+ {
+ let c__0 = [];
+ let c4 = [], p4 = {key:4};
+ let vn4 = h('p', p4, c4);
+ c__0.push(vn4);
+ c4.push({text: \`antony\`});
+ scope[utils.zero] = c__0;
+ }
+ result = []
+ this.constructor.subTemplates['1'].call(this, scope, Object.assign({}, extra, {parentNode: result, parent: utils.getComponent(context), key: '__5__'}));
+ result = result[0]
+ }
+ scope = _origScope3;
+ return result;
+}"
+`;
+
exports[`t-call (template calling t-call with t-if 1`] = `
"function anonymous(context, extra
) {
diff --git a/tests/qweb/qweb.test.ts b/tests/qweb/qweb.test.ts
index 24b6908e..35a2d2b4 100644
--- a/tests/qweb/qweb.test.ts
+++ b/tests/qweb/qweb.test.ts
@@ -1096,6 +1096,13 @@ describe("t-call (template calling", () => {
expect(renderToString(qweb, "main")).toBe(expected);
});
+ test("t-call with body content as root of a template", () => {
+ qweb.addTemplate("antony", ``);
+ qweb.addTemplate("main", `antony
`);
+ const expected = "antony
";
+ expect(renderToString(qweb, "main")).toBe(expected);
+ });
+
test("dynamic t-call", () => {
qweb.addTemplate("foo", ``);
qweb.addTemplate("bar", ``);