[FIX] web: qweb: correctly set preprocess_node on qweb engine
issue: xml template are not translated anymore revd56b35e2moved 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 revd56b35e2) 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.
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user