Including partials dynamically
See original GitHub issueHi,
I have been looking for a simple way to dynamically render partials based on a value in an {{#each ...}}
loop.
For example:
{{#each modules}}
{{> @exphbs.partials[ this.name ] }}
{{/each}}
This would allow me to load partials based on data rather than putting a lot of logic in the template.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:3
- Comments:8 (3 by maintainers)
Top Results From Across the Web
How do I load different partials dynamically using handlebars ...
First, pull in your dynamic partials before rendering, something like: ... So when you use a helper to include a partial then Handlebars ......
Read more >How to best dynamically include partials in a view? - Laracasts
In my example, I'm looking to include partials based upon the property of an object. I could simply do a if-else, but that...
Read more >Partials | Handlebars
Dynamic Partials. It's possible to dynamically select the partial to be executed by using sub expression syntax. template
Read more >How to build a dynamic partial? - How To - Wappler Community
In my nodejs content page, I have 4 tables with same content inside. The only changes in this bootstrap table is that the...
Read more >Handlebars: Dynamic Partial
Samples · The return value of helper foo will be partial name · When partial name is not exist it will cause runtime...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Looking at the unit tests the subexpression needs to be a helper. Something like this:
If you’re using the handlebar-helpers library you can use a standard string function such as
lowercase
. It might not do anything but it returns a function and fixes this niggle.