Handlebars render helper
Render handlebars partials in a specific outlet, similar to ember {{outlet}}
helper.
How to register helper
let handlebars = ;let render = ; // call render with your handlebars instance, it will return the helperhandlebars;
Use cases
Imagine the following situation: you have menu
component,
depending of the webpage, you want to display different items inside the menu. if you have used mustache before,
you may end up doing this:
menu.hbs
{{# homepage }} {{> display-list-1}} {{/ homepage }} {{# contact}} {{> display-other-list}} {{/ contact}}
other-component.hbs
{{> menu homepage=true}}
output.html
example 1
The main problem is that your component end up knowing all possible uses cases, creating a unwanted component logic. This helper allows you to pass your logic code as block, like this:
menu.hbs
{{outlet}}
other-component.hbs
{{#render "menu"}} {{> display-list-1}}{{/render}}
output.html
example 1