I'm using dust templates and one aspect of the design has been bugging me. This makes me wonder if I'm "doing it wrong" so I thought I would ask S.O. Is there a way to create multiple-level inheritance in dust.js with blocks and inline partials? Lets say you have a base template with layout, an inheriting template that overrides some content, and then yet another template inheriting from that template that wishes to selectively override some content. Normally I would imagine it works by the last inheriting template providing the final overriding values. The inline partial syntax, however, seems to only work on a single level. Here's a contrived example that should show what I'm talking about.
template 1 test_base.dust
:
<h1>
{+document_title/}
</h1>
{+content}
<p>Some great content.</p>
{/content}
template 2 test_level1.dust
:
{>test_base/}
{<document_title}Level 1{/document_title}
{<content}
<p>Other great content</p>
{/content}
template 3 test_level2.dust
:
{>test_level1/}
{<document_title}Level 2{/document_title}
Rendering these templates I get the following results:
dust.render('test_base', {}, function(err, data) { console.log(data); } );
"<h1></h1><p>Some great content.</p>"
dust.render('test_level1', {}, function(err, data) { console.log(data); } );
"<h1>Level 1</h1><p>Other great content</p>"
dust.render('test_level2', {}, function(err, data) { console.log(data); } );
"<h1>Level 1</h1><p>Other great content</p>"
I've read over the docs a few times but it seems like you can inherit templates from multiple levels but you can only override a single template defined block. So am I "doing it wrong"? Is there a way to accomplish multiple level inheritance with selective overrides using blocks and inline partials? Is there another way to do this and keep the templates DRY?