[ADD] Added clone template in QWeb2 (t-name & t-extend)
bzr revid: fme@openerp.com-20110509121901-kmpcn7n6gsrjx6bl
This commit is contained in:
@@ -24,4 +24,9 @@
|
||||
<t t-extend="jquery-extend">
|
||||
<t t-jquery="footer" t-operation="inner"><b>END</b></t>
|
||||
</t>
|
||||
|
||||
<t t-name="jquery-extend-clone" t-extend="jquery-extend">
|
||||
<t t-jquery="ul" t-operation="append"><li>CLONED TEMPLATE</li></t>
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
|
||||
@@ -251,6 +251,8 @@
|
||||
test("jQuery extend", function () {
|
||||
equals(render('jquery-extend', {}), '<hr/><ul class="main"><li>1</li><li>2</li><li>3</li></ul><footer><b>END</b></footer>',
|
||||
"Extend template with jQuery");
|
||||
equals(render('jquery-extend-clone', {}), '<ul><li>one</li><li>CLONED TEMPLATE</li></ul>',
|
||||
"Clone template");
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -216,6 +216,15 @@ QWeb2.Engine = (function() {
|
||||
}
|
||||
var name = node.getAttribute(this.prefix + '-name');
|
||||
var extend = node.getAttribute(this.prefix + '-extend');
|
||||
if (name && extend) {
|
||||
// Clone template and extend it
|
||||
if (!this.templates[extend]) {
|
||||
return this.tools.exception("Can't clone undefined template " + extend);
|
||||
}
|
||||
this.templates[name] = this.templates[extend].cloneNode(true);
|
||||
extend = name;
|
||||
name = undefined;
|
||||
}
|
||||
if (name) {
|
||||
this.templates[name] = node;
|
||||
} else if (extend) {
|
||||
|
||||
Reference in New Issue
Block a user