Ticket #8291 (closed defect: fixed)
dojox.dtl - Template inheritance ('extends' tag) broken in trunk
| Reported by: | rsaccon | Owned by: | pottedmeat |
|---|---|---|---|
| Priority: | high | Milestone: | 1.3 |
| Component: | DojoX DTL | Version: | 1.2.3 |
| Severity: | major | Keywords: | dojox, dtl, extends |
| Cc: |
Description
When I updated from a dojo version < 1.2, I realized that the 'extends' tag does not work anymore properly. I have observed the following behavior: if the child template (the one 'extending' the parent template) contains just text or a single DOM node, everything is fine. If it contains a more complex DOM node structure, only the first node gets rendered at the first rendering cycle (in a HtmlTemplated?.js widget), at successive rendering cycles the whole node-list gets rendered but with wrong order of nodes.
Unfortunately the test-suite does only contain an empty dummy test for the 'extends' tag. Following are two simple test cases (for copy-pasting into 'dojox.dtl.tests.html.tag') illustrating the problem for the first rendering cycle.
function test_tag_extendOk(t){
var dd = dojox.dtl;
var context = new dd.Context({
base: dojo.moduleUrl("dojox.dtl.tests.templates", "base.html")
});
var template = new dd.HtmlTemplate("{% extends base %}{% block base %}<p>1</p>{% endblock %}");
t.is("<div>BaseBefore<p>1</p>BaseAfter</div>", dd.tests.html.util.render(template, context));
},
function test_tag_extendFailure(t){
var dd = dojox.dtl;
var context = new dd.Context({
base: dojo.moduleUrl("dojox.dtl.tests.templates", "base.html")
});
var template = new dd.HtmlTemplate("{% extends base %}{% block base %}<p>1</p><p>2</p>{% endblock %}");
t.is("<div>BaseBefore<p>1</p><p>2</p>BaseAfter</div>", dd.tests.html.util.render(template, context));
},
feel free to contact me anytime at rsaccon at gmail, if further information is required or if I can help to implement a fix.