[TEST] add tests for t-raw and t-rawf, fix rawf which has apparently been broken since forever ago

bzr revid: xmo@openerp.com-20110310092356-xgfyjpdct2afotbv
This commit is contained in:
Xavier Morel
2011-03-10 10:23:56 +01:00
parent fdda52a3a4
commit 84b0da12ae
3 changed files with 40 additions and 1 deletions
@@ -23,4 +23,29 @@
<t t-name="escf-format-variable-with-escapes">
<t t-escf="[#{value}]"/>
</t>
<!-- raw, evaluates and returns @t-raw directly (no escaping) -->
<t t-name="raw-literal">
<t t-raw="'ok'"/>
</t>
<t t-name="raw-variable">
<t t-raw="ok"/>
</t>
<t t-name="raw-notescaped">
<t t-raw="ok"/>
</t>
<!-- rawf, same as t-raw, but @t-rawf is a format string -->
<t t-name="rawf-noformat-literal">
<t t-escf="ok"/>
</t>
<t t-name="rawf-simpleformat-variable">
<t t-escf="#{value}"/>
</t>
<t t-name="rawf-format-variable">
<t t-escf="[#{value}]"/>
</t>
<t t-name="rawf-format-variable-notescaped">
<t t-rawf="[#{value}]"/>
</t>
</templates>
+14
View File
@@ -40,6 +40,20 @@
equals('[&lt;ok&gt;]', render('escf-format-variable-with-escapes', {value: '<ok>'}),
"Render a formatted string with data to escape");
});
test("Basic unescaped output", function () {
equals("ok", render('raw-literal', {}), "Render a literal string");
equals("ok", render('raw-variable', {ok: 'ok'}), "Render a string variable");
equals("<ok>", render('raw-notescaped', {ok: '<ok>'}), "Render a string with data not escaped");
});
test("Formatted unescaped output", function () {
equals("ok", render('rawf-noformat-literal', {}), "Render a literal string");
equals("ok", render('rawf-simpleformat-variable', {value: 'ok'}),
"Only render an interpolated variable");
equals("[ok]", render('rawf-format-variable', {value: 'ok'}),
"Actually formatted variable");
equals('[<ok>]', render('rawf-format-variable-notescaped', {value: '<ok>'}),
"Render a formatted string with data not escaped");
});
});
</script>
+1 -1
View File
@@ -174,7 +174,7 @@ var QWeb = {
return this.eval_str(t_att["raw"], v);
},
render_tag_rawf:function(e, t_att, g_att, v) {
return this.eval_format(t_att["raw"], v);
return this.eval_format(t_att["rawf"], v);
},
render_tag_esc:function(e, t_att, g_att, v) {
return this.escape_text(this.eval_str(t_att["esc"], v));