Search code examples
htmlyamlhandlebars.jsassemble

Assemble, Handlebars partial, YAML Front matter


I have a partial... e.g: partial.hbs

<h1>{{title}}</h1>

I want to use this partial but pass the YAML "title" in another partial e.g: page.hbs

---
 title: hello
---
{{> partial}}

is this possible without writing a custom helper?


Solution

  • in Assemble 0.4.x with Handlebars 2.x you should be able to pass arguments to partials, so your use of the partial.hbs would be something like:

    page.hbs

    ---
     title: hello
    ---
    {{> partial title=title}}
    

    just be sure you are using Handlebars <=2.0 which supports partial parameters/arguments.

    otherwise you could take a look at the handlebars-helper-partial which can do this with <2.0 Handlebars.

    hope this helps.