summaryrefslogtreecommitdiff
path: root/addons/web/static/lib/qweb/qweb2.js
diff options
context:
space:
mode:
authorXavier Morel <xmo@openerp.com>2014-09-11 10:51:08 +0200
committerXavier Morel <xmo@openerp.com>2014-10-06 19:13:45 +0200
commitd5e3d121e3733de189605da7f830ff3d7c20b8d8 (patch)
tree4daf7ad43b8cb665261387860a950283cced2615 /addons/web/static/lib/qweb/qweb2.js
parent2ffcff8fa9bd58beee33170be5a11649ec282602 (diff)
[ADD] qweb: call directive's body
* __content__ can't be used in Python implementation because safe_eval, so use ``0`` from Python implementation instead * remove postfix from t-call tests because due to implementation details all whitespace crap following a t-name is added to rendered template in Python impl, and don't want to normalize whitespace.
Diffstat (limited to 'addons/web/static/lib/qweb/qweb2.js')
-rw-r--r--addons/web/static/lib/qweb/qweb2.js11
1 files changed, 8 insertions, 3 deletions
diff --git a/addons/web/static/lib/qweb/qweb2.js b/addons/web/static/lib/qweb/qweb2.js
index e080476cec9..c845abd5965 100644
--- a/addons/web/static/lib/qweb/qweb2.js
+++ b/addons/web/static/lib/qweb/qweb2.js
@@ -26,7 +26,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// TODO: templates orverwritten could be called by t-call="__super__" ?
// TODO: t-set + t-value + children node == scoped variable ?
var QWeb2 = {
- expressions_cache: {},
+ expressions_cache: {
+ // special case for template bodies, __content__ doesn't work in
+ // Python impl because safe_eval -> assert_no_dunder_name so use
+ // Python impl's magical 0 variable instead
+ '0': 'dict[0]',
+ },
RESERVED_WORDS: 'true,false,NaN,null,undefined,debugger,console,window,in,instanceof,new,function,return,this,typeof,eval,void,Math,RegExp,Array,Object,Date'.split(','),
ACTIONS_PRECEDENCE: 'foreach,if,call,set,esc,raw,js,debug,log'.split(','),
WORD_REPLACEMENT: {
@@ -137,7 +142,7 @@ var QWeb2 = {
var new_dict = this.extend({}, old_dict);
new_dict['__caller__'] = old_dict['__template__'];
if (callback) {
- new_dict['__content__'] = callback(context, new_dict);
+ new_dict[0] = callback(context, new_dict);
}
return context.engine._render(template, new_dict);
},
@@ -551,7 +556,7 @@ QWeb2.Element = (function() {
format_expression : function(e) {
/* Naive format expression builder. Replace reserved words and variables to dict[variable]
* Does not handle spaces before dot yet, and causes problems for anonymous functions. Use t-js="" for that */
- if (QWeb2.expressions_cache[e]) {
+ if (QWeb2.expressions_cache[e]) {
return QWeb2.expressions_cache[e];
}
var chars = e.split(''),