diff options
| author | Fabien Meghazi <fme@openerp.com> | 2012-02-07 14:29:01 +0100 |
|---|---|---|
| committer | Fabien Meghazi <fme@openerp.com> | 2012-02-07 14:29:01 +0100 |
| commit | ce65bc3ac37934a27045e8af3d43fc0accf35f3c (patch) | |
| tree | 5504c739a2a1f66487aefdcfdff5a5b05d68d2ee /addons/web/static/lib/qweb/qweb2.js | |
| parent | b5579eee208bf12a4d591e45f3b5ea21cbec69c0 (diff) | |
[IMP] Add QWeb preprocess_node callback. Translate @label, @title and @alt attributes in web client
bzr revid: fme@openerp.com-20120207132901-ifwnfj6c4mp451tl
Diffstat (limited to 'addons/web/static/lib/qweb/qweb2.js')
| -rw-r--r-- | addons/web/static/lib/qweb/qweb2.js | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/addons/web/static/lib/qweb/qweb2.js b/addons/web/static/lib/qweb/qweb2.js index 1ec2a37c02d..9845889a0b7 100644 --- a/addons/web/static/lib/qweb/qweb2.js +++ b/addons/web/static/lib/qweb/qweb2.js @@ -55,7 +55,7 @@ var QWeb2 = { if (o !== null && o !== undefined) { if (o.constructor === Array) { if (o[1] !== null && o[1] !== undefined) { - return ' ' + o[0] + '="' + this.html_escape(o[1], true) + '"'; + return this.format_attribute(o[0], o[1]); } } else if (typeof o === 'object') { var r = ''; @@ -69,6 +69,9 @@ var QWeb2 = { } return ''; }, + format_attribute: function(name, value) { + return ' ' + name + '="' + this.html_escape(value, true) + '"'; + }, extend: function(dst, src, exclude) { for (var p in src) { if (src.hasOwnProperty(p) && !(exclude && this.arrayIndexOf(exclude, p) !== -1)) { @@ -193,7 +196,7 @@ QWeb2.Engine = (function() { this.reserved_words = QWeb2.RESERVED_WORDS.slice(0); this.actions_precedence = QWeb2.ACTIONS_PRECEDENCE.slice(0); this.word_replacement = QWeb2.tools.extend({}, QWeb2.WORD_REPLACEMENT); - this.format_text_node = null; + this.preprocess_node = null; for (var i = 0; i < arguments.length; i++) { this.add_template(arguments[i]); } @@ -437,6 +440,9 @@ QWeb2.Element = (function() { } } } + if (this.engine.preprocess_node) { + this.engine.preprocess_node.call(this); + } } QWeb2.tools.extend(Element.prototype, { @@ -472,11 +478,7 @@ QWeb2.Element = (function() { switch (this.node.nodeType) { case 3: case 4: - var text = this.node.data; - if (this.engine.format_text_node) { - text = this.engine.format_text_node.call(this, text); - } - this.top_string(text); + this.top_string(this.node.data); break; case 1: this.compile_element(); |
