Closed zsteiner closed 4 years ago
{{> @partial-block}}
should be the correct way to call it. As far as I can see, it the @partial-block
is just an inline partial that is implicitly registered when a partial is called like {{#> partial}} block {{/partial}}
.
All the test-cases also use {{> @partial-block }}
.
{{ @partial-block }}
works up to 4.0.6. But in 4.0.7 and later, you'll loose some context (see wycats/handlebars.js#1445).
Still, could you tell me where you got the idea that {{@partial-block}}
is correct? Maybe it is documented wrongly somewhere and we need to fix that.
I tried to replicate what we're seeing in a our project, which is private repo using Fabricator (https://fbrctr.github.io).
https://codepen.io/zsteiner/pen/XYvQVb
In the pen, there's a partial called wrapper that has some HTML inserted into it. It only works with {{{ @partial-block }}}
. We are heavily using this pattern to insert HTML or other nested Handlebars partials into a partial for better reusability.
It may be a version issue and will trying updating the version to most recent.
{{{@partial-block}}}
works because the the compiled partial-block is added to data
-frame as partial-block
, similar to @index
in the each
-helper. Since it is a function, it is executed when using {{{@partial-block}}}
and the result of the function is inserted without HTML escape.
But this usage works only by accident. It is NOT how it should be used and from my point of view, could change without a major-version increment. Although I would probably not do that, given that multiple people are already using it this way.
However, wycats/handlebars.js#1445 is an example of why you should not use it this way.
Instead, you should replace {{{@partial-block}}}
with {{> @partial-block}}
in all places. Your example in the codepen works fine with this change.
http://handlebarsjs.com/partials.html
The section that discusses Partial Blocks has a syntax error:
Site Content {{> @partial-block }}
The partial-block should not have a greater than symbol. The documentation should read:
Site Content {{ @partial-block }}