diff --git a/addons/web/static/lib/qweb/qweb-test-call.xml b/addons/web/static/lib/qweb/qweb-test-call.xml index f71aca0b2ca..783172c73bd 100644 --- a/addons/web/static/lib/qweb/qweb-test-call.xml +++ b/addons/web/static/lib/qweb/qweb-test-call.xml @@ -1,6 +1,6 @@ ok - + @@ -32,11 +32,18 @@ ok + - - + - 1 - 1 + 1 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(''), diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 32ef66d697b..3eb4638ac53 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -577,7 +577,7 @@
- +
    +The body of the ``call`` directive can be arbitrarily complex (not just +``set`` directives), and its rendered form will be available within the called +template as a magical ``0`` variable:: + +
    + This template was called with content: + +
    + +being called thus:: + + + content + + +will result in:: + +
    + This template was called with content: + content +
    + Python ======