Skip to content
  • home
  • portfolio
  • web design journal
  • blog
    • adventure
    • san diego
    • projects
    • website design
    • code notes
Blog Web Dev Reference a Handlebars Template From Another Template (Nesting Templates)

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.

Posted on May 19, 2015August 26, 2022 in Web Dev

drempd | san diego, ca


home contact

adventures san diego projects stream website design

portfolio resume san diego web design freelance web designer

custom web design responsive web design website maintenance