[IMP] web: extend qweb to allow dynamic templates in t-call
Before this change the t-call can use only receive a literal as parameters:
<t t-call="template.name17" />
This call render the template 'template.name17' with the current context.
Now, we can defined an expression with braces (same syntax that t-attf):
<t t-call="template.name{{ 10 + 7 }}" />
This call render the template 'template.name17' with the current context.
This change allows for greater flexibility for applications using qweb.
(The performance due to this change is unchanged during rendering time.)
This commit is contained in:
@@ -55,4 +55,9 @@
|
||||
<result id="scoped-parameter">
|
||||
ok
|
||||
</result>
|
||||
|
||||
<t t-name="basic-caller">
|
||||
<t t-call="{{True and '_basic-callee' or 'other'}}"/>
|
||||
</t>
|
||||
<result id="basic-caller">ok</result>
|
||||
</templates>
|
||||
|
||||
@@ -785,9 +785,9 @@ QWeb2.Element = (function() {
|
||||
},
|
||||
compile_action_call : function(value) {
|
||||
if (this.children.length === 0) {
|
||||
return this.top("r.push(context.engine.tools.call(context, " + (this.engine.tools.js_escape(value)) + ", dict));");
|
||||
return this.top("r.push(context.engine.tools.call(context, " + (this.string_interpolation(value)) + ", dict));");
|
||||
} else {
|
||||
this.top("r.push(context.engine.tools.call(context, " + (this.engine.tools.js_escape(value)) + ", dict, null, function(context, dict) {");
|
||||
this.top("r.push(context.engine.tools.call(context, " + (this.string_interpolation(value)) + ", dict, null, function(context, dict) {");
|
||||
this.bottom("}));");
|
||||
this.indent();
|
||||
this.top("var r = [];");
|
||||
|
||||
@@ -1475,7 +1475,7 @@ class QWeb(object):
|
||||
ctx=ast.Load()
|
||||
),
|
||||
args=[
|
||||
ast.Str(str(tmpl)),
|
||||
self._compile_format(str(tmpl)),
|
||||
ast.Name(id=name_options, ctx=ast.Load()),
|
||||
],
|
||||
keywords=[], starargs=None, kwargs=None
|
||||
|
||||
Reference in New Issue
Block a user