[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:
@@ -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>
|
||||
|
||||
@@ -40,6 +40,20 @@
|
||||
equals('[<ok>]', 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>
|
||||
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user