akdubya / dustjs

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

Partials with block content #35

Open laurie71 opened 13 years ago

laurie71 commented 13 years ago

The peg grammar treats partials differently from other sections, requiring the 'partial' tag to be self-closing, so it isn't valid to do

{>partial}...stuff...{/partial}

Could support for this be added, along with blocks, so you could write, for example:

{>partial}
    {<heading}Title{/heading}
    {<content}
        ...markup...
    {/content}
{/partial}

The heading/content sections would remain on the context stack for the duration of partial, then be popped.

This would be a more natural syntax when using inline partials for layout but, more importantly, it would allow partials to be reused within a page for rendering repeating elements with varying content. I'd use this, for example, to standardize how forms are marked up across an app/site whilst keeping the actual form elements local to the calling template.