shannonmoeller / handlebars-layouts

Handlebars helpers which implement layout blocks similar to Jinja, Nunjucks (Swig), Pug (Jade), and Twig.
http://npm.im/handlebars-layouts
MIT License
361 stars 29 forks source link

Extending block pollute each others output #35

Closed Florian-R closed 8 years ago

Florian-R commented 8 years ago

Sorry for the weird title, but this is a tricky one and couldn't really find a good name for this issue.

See this requirebin for more context.

I'm not sure I'm not doing something totally wrong here, so let me know if I miss something and I'll try to fill a PR if it's totally valid scenario.

shannonmoeller commented 8 years ago

When you want to include a partial that itself extends a layout, you can't use the {{> partial}} syntax. You use {{#embed 'partial'}}{{/embed}} or {{{embed 'partial'}}} instead. If you change the container template in the <body> of your demo to the following, it works as expected:

<script type="text/template" id="container">
{{#extend 'otherBase'}}
  {{#content 'otherBaseContent'}}
    {{{embed 'firstDescendant'}}}
    {{{embed 'secondDescendant'}}}
  {{/content}}  
{{/extend}}  
</script>

https://github.com/shannonmoeller/handlebars-layouts#embed-partial-context-keyvalue-

Florian-R commented 8 years ago

Ah my bad, I knew about embed, but always use it instead of extend, not when calling directly the partial.

/me being dumb, closing this

shannonmoeller commented 8 years ago

No worries. Not dumb. Maybe this thread will help someone else too.