Skip to content

Instantly share code, notes, and snippets.

@leegee
Created November 2, 2017 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leegee/cd473d20b8df775ba48ea4504e67d184 to your computer and use it in GitHub Desktop.
Save leegee/cd473d20b8df775ba48ea4504e67d184 to your computer and use it in GitHub Desktop.
Handlebars template to include other templates from DOM
el.main.innerHTML = Handlebars.compile(
el.innerHTML.toString()
)(
{ myContext: this }
);
// {{#includeDomTemplate "publish-tables-and-skus"}}{{/includeDomTemplate}}
Handlebars.registerHelper('includeDomTemplate', function(templateId) {
var html = Handlebars.compile(
document.getElementById(templateId).innerHTML.toString()
)(
{ myContext: this.myContext }
);
return new Handlebars.SafeString(html);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment