[FIX] qweb: allow t-if with t-call directives

closes #246
This commit is contained in:
Géry Debongnie
2019-07-16 13:17:51 +02:00
parent 5382e824b1
commit b1d022b583
3 changed files with 27 additions and 0 deletions
+4
View File
@@ -228,6 +228,10 @@ QWeb.addDirective({
ctx.addLine("}");
}
if (node.hasAttribute("t-if") || node.hasAttribute("t-else") || node.hasAttribute("t-elif")) {
ctx.closeIf();
}
return true;
}
});
@@ -806,6 +806,22 @@ exports[`t-call (template calling scoped parameters 1`] = `
}"
`;
exports[`t-call (template calling t-call with t-if 1`] = `
"function anonymous(context,extra
) {
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
if (context['flag']) {
let c2 = [], p2 = {key:2};
var vn2 = h('span', p2, c2);
c1.push(vn2);
c2.push({text: \`ok\`});
}
return vn1;
}"
`;
exports[`t-call (template calling with unused body 1`] = `
"function anonymous(context,extra
) {
+7
View File
@@ -501,6 +501,13 @@ describe("t-call (template calling", () => {
expect(renderToString(qweb, "caller")).toBe(expected);
});
test("t-call with t-if", () => {
qweb.addTemplate("sub", "<span>ok</span>");
qweb.addTemplate("caller", '<div><t t-if="flag" t-call="sub"/></div>');
const expected = "<div><span>ok</span></div>";
expect(renderToString(qweb, "caller", {flag: true})).toBe(expected);
});
test("t-call not allowed on a non t node", () => {
qweb.addTemplate("_basic-callee", "<t>ok</t>");
qweb.addTemplate("caller", '<div t-call="_basic-callee"/>');