summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/framework/qweb.js
diff options
context:
space:
mode:
authorSimon Lejeune <sle@openerp.com>2016-07-06 14:55:10 +0200
committerSimon Lejeune <sle@openerp.com>2016-07-06 15:49:01 +0200
commitcb30d0ef0e2f113807c64fc99013efbd79e414e0 (patch)
treed9105b0dd1bda147b7f61ad0353b103432a825b0 /addons/web/static/src/js/framework/qweb.js
parentab1fb148a98cfccdc969a62b999e531b845c53a6 (diff)
[FIX] web: qweb: correctly set `preprocess_node` on qweb engine
issue: xml template are not translated anymore rev d56b35e2 moved qweb code inside the `qweb.js` file and also changed the behavior with the introduction of a `QWeb` factory returning instances of qweb rendering engine. However, we have to set on the rendering engine instance a `preprocess_node` function that will translate the qweb templates. The solution for this issue (also introduced with rev d56b35e2) was to set this function on the prototype of the QWeb factory, and it was obviously not enough as it has to be attached to the rendering engine instance. In order to benefit from the fact that the `preprocess_node` function is attached to the prototype of the QWeb factory, we could attach it to the rendering engine instance with something like `qweb.preprocessed_node = this.preprocessed_node`, however i find that conceptually attaching a translate function to a factory does not make sense, si i simply made `preprocess_node` a free function and i set it on rendering engine instance.
Diffstat (limited to 'addons/web/static/src/js/framework/qweb.js')
-rw-r--r--addons/web/static/src/js/framework/qweb.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/addons/web/static/src/js/framework/qweb.js b/addons/web/static/src/js/framework/qweb.js
index 39066216737..50742075e05 100644
--- a/addons/web/static/src/js/framework/qweb.js
+++ b/addons/web/static/src/js/framework/qweb.js
@@ -16,10 +16,11 @@ function QWeb(debug, default_dict) {
'csrf_token': odoo.csrf_token,
});
qweb.debug = debug;
+ qweb.preprocess_node = preprocess_node;
return qweb;
}
-QWeb.prototype.preprocess_node = function() {
+function preprocess_node() {
// Note that 'this' is the Qweb Node
switch (this.node.nodeType) {
case Node.TEXT_NODE:
@@ -43,7 +44,7 @@ QWeb.prototype.preprocess_node = function() {
}
}
}
-};
+}
return QWeb;