I have a folder structure like so:
- components/
  - foo/
     - index.js
     - foo.handlebars
     - foo.scss
  - bar/
     - index.js
     - bar.handlebars
     - bar.handlebars
In order to resolve component partials conveniently I provide a helper that will find a correct path, translating bar into components/bar/bar.handlebars. This helper is called getPartialForTemplate.
In my template, I do:
{{> (getPartialForTemplate 'foo') some=props}}
This is fine, but when I need to use the resolved template as a block I come across an issue:
{{#> (getPartialForTemplate 'foo')}}
  <p>Some text here..</p>
{{/WHATGOESHERE???}}
This seems like a syntax flaw in Handlebars, as I'd expect its syntax features to work together. Is there a way to do this?
There's an open issue on github, the suggested workaround is this:
{{#>( lookup . 'intendedTemplate' )}}
  No template matched for "{{intendedTemplate}}"
{{/undefined}}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With