mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] qweb: handle variable expressions in t-if
closes #390 closes #362
This commit is contained in:
@@ -1502,6 +1502,22 @@ exports[`t-if t-esc with t-if 1`] = `
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-if t-set, then t-if 1`] = `
|
||||
"function anonymous(context,extra
|
||||
) {
|
||||
var h = this.h;
|
||||
let c1 = [], p1 = {key:1};
|
||||
var vn1 = h('div', p1, c1);
|
||||
var _2 = 'test';
|
||||
if ('test') {
|
||||
if (_2 || _2 === 0) {
|
||||
c1.push({text: _2});
|
||||
}
|
||||
}
|
||||
return vn1;
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-key can use t-key directive on a node 1`] = `
|
||||
"function anonymous(context,extra
|
||||
) {
|
||||
|
||||
@@ -338,6 +338,17 @@ describe("t-if", () => {
|
||||
qweb.addTemplate("test", `<div><t t-if="false">abc</t><t t-else="1" t-esc="'x'"/></div>`);
|
||||
expect(renderToString(qweb, "test")).toBe("<div>x</div>");
|
||||
});
|
||||
|
||||
test("t-set, then t-if", () => {
|
||||
qweb.addTemplate("test", `
|
||||
<div>
|
||||
<t t-set="title" t-value="'test'"/>
|
||||
<t t-if="title"><t t-esc="title"/></t>
|
||||
</div>`);
|
||||
const result = renderToString(qweb, "test");
|
||||
const expected = `<div>test</div>`;
|
||||
expect(result).toBe(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe("attributes", () => {
|
||||
|
||||
Reference in New Issue
Block a user