Search code examples
mustachehandlebars.js

Is it possible to insert something into a partial?


Is it possible to use partials as wrapper? Like the following example

I don't want to use a variable like {{> myPartial foo='bar' }}

someView.hbs

{{> myPartial }}
  foo bar 
{{/ myPartial }}

myPartial.hbs

<!-- ... -->
{{myPlaceholder}}

Solution

  • Yes. See http://handlebarsjs.com/partials.html#partial-block

    someView.hbs

    {{#> myPartial }}
      foo bar 
    {{/ myPartial }}
    

    myPartial.hbs

    <!-- ... -->
    {{> @partial-block }}