Reference a Handlebars Template From Another Template (Nesting Templates)
By Forrest Smith - Drempd.com
Within the JS file, register a new partial (note: avoid underscores with with the name of the partial, or with the template names…this seems to cause issues):
Handlebars.registerPartial("inner-template",$("#tpl-inner-template").html());
In the template template that you want to include the partial in, just reference the partial with:
{{> inner-template Data }}
If the data isn’t showing, try adding a .
I was initially getting an error like “The partial inner-template could not be found”. This was because within the code, I was attempting to register the partial afer I attempted to render out the handlebars template. I swapped these around, and it worked like a charm.
-
Adventure
-
The Built Environment
-
Locations
-
Web Dev