[FIX] qweb: fix issue with expression formatting

closes #21
This commit is contained in:
Géry Debongnie
2019-04-12 15:08:14 +02:00
parent f300e921d6
commit 2ea01455cb
3 changed files with 29 additions and 2 deletions
+14 -1
View File
@@ -105,7 +105,7 @@ exports[`attributes from object variables set previously 1`] = `
var h = this.utils.h;
var c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
var _2 = {a:'b'}.a;
var _2 = {a: 'b'}.a;
var c3 = [], p3 = {key:3,attrs:{class: _2}};
var vn3 = h('span', p3, c3);
c1.push(vn3);
@@ -1310,6 +1310,19 @@ exports[`t-set set from empty body 1`] = `
}"
`;
exports[`t-set t-set and t-if 1`] = `
"function anonymous(context,extra
) {
var h = this.utils.h;
var c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
if (context['value'] === 'ok') {
c1.push({text: \`grimbergen\`});
}
return vn1;
}"
`;
exports[`t-set value priority 1`] = `
"function anonymous(context,extra
) {
+13
View File
@@ -195,6 +195,19 @@ describe("t-set", () => {
expect(renderToString(qweb, "test")).toBe("<div>ok</div>");
});
test("t-set and t-if", () => {
qweb.addTemplate(
"test",
`<div >
<t t-set="v" t-value="value"/>
<t t-if="v === 'ok'">grimbergen</t>
</div>`
);
expect(renderToString(qweb, "test", { value: "ok" })).toBe(
"<div>grimbergen</div>"
);
});
test("set from body literal", () => {
qweb.addTemplate(
"test",