"yield" or "body" method?
Opened this issue · 1 comments
A common use case is to have a layout like so
layout.dust
<h1>header</h1>
{=body}
<p>Footer</p>
And then have a template use that layout
home.dust
{>layout}
<p>I am the content</p>
Which would render:
<h1>header</h1>
<p>I am the content</p>
<p>Footer</p>
Right now I'm doing it like this:
layout.dust
<h1>header</h1>
{+body}{/body}
<p>Footer</p>
home.dust
{>layout/}
{<body}
<p>I am the content</p>
{/body}
Is the first way supported? If not, consider this a feature request :)
We are using the second pattern,
initially it was a little confusing, but now we have got used to it ..
we use it for other things too
Most often we tend to reuse the same data in the template again and again ... One way to avoid been repetitive is use aliases. So a common question was, how does dust support this ?
Well, in dust there is more than one way neat way to do this.
Use Inline Partials
Inline partials never output content themselves, and are always global to the template in which they are defined, so the order of their definition has no significance.
Key points to note : They are global to the template., there is no ordering and can be defined anywhere
Step 1 create global alias
{<greeting}Hello, Hola{/greeting}
Step 2
{#names}
{.} {+greeting/}
{/names}
{#projects}
{.} {+greeting/}
{/projects}