[FIX] t-out: allow expressions evaluating as number

This commit is contained in:
Géry Debongnie
2022-06-07 10:33:59 +02:00
committed by Sam Degueldre
parent 1fc88f626f
commit a3111eb9ca
3 changed files with 44 additions and 13 deletions
@@ -79,6 +79,21 @@ exports[`t-out not escaping 1`] = `
}"
`;
exports[`t-out number literal 1`] = `
"function anonymous(app, bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
let { safeOutput } = helpers;
let block1 = createBlock(\`<span><block-child-0/></span>\`);
return function template(ctx, node, key = \\"\\") {
const b2 = safeOutput(1);
return block1([], [b2]);
}
}"
`;
exports[`t-out t-out 0 1`] = `
"function anonymous(app, bdom, helpers
) {
+5
View File
@@ -27,6 +27,11 @@ describe("t-out", () => {
expect(renderToString(template)).toBe("<span>ok</span>");
});
test("number literal", () => {
const template = `<span><t t-out="1"/></span>`;
expect(renderToString(template)).toBe("<span>1</span>");
});
test("literal, no outside html element", () => {
const template = `<t t-out="'ok'"/>`;
expect(renderToString(template)).toBe("ok");