akdubya / dustjs

Asynchronous templates for the browser and node.js
http://akdubya.github.com/dustjs/
MIT License
1.44k stars 131 forks source link

Nested templates don't support multi-level block overrides #30

Open laurie71 opened 13 years ago

laurie71 commented 13 years ago

I'd like to have a 'base' layout, section specific layouts that extend the base layout, then pages extending the section specific layouts. However I can't get blocks in the page templates to show up if they're defined in the section template. Here's a simple example:

base.dust (html) (head) (title){+title}Home{/title} : MySite(/title) {+head/} (/head) (body){+body/}(/body) (/html)

section1.dust {>base/} {<head} (script src="...")(/script) {/head}

page1.dust {>section1/} {<title}Page 1{/title} {<head} (link rel=stylesheet href="...") {/head} {<body} PAGE BODY {/body}

The desired result would be a page with both the 'script' tag and the stylesheet 'link' tag in the head. How do I do that, without having to define new blocks in each template? (which would be problematic if the number of nested templates varied from page to page)

Here's a fiddle where I've been playing with this, for reference: http://jsfiddle.net/laurie/dxDyN/1/