gruntjs/grunt-contrib-handlebars

compiling partials as templates

Opened this issue · 3 comments

Outside of node.js I have always set all my templates to be partials so I can use any template anywhere. I cannot figure out a way to do this with grunt pre-compilation. Is there a way to do this?

You can set partialRegex to /.*/. Only problem I have with that is that if you're using AMD it won't return the instance of Handlebars :-(

Related to #115

My question is how you would use this partials ?

If anyone is still wondering, partials exist on the instance of Handlebars you are using, so Handebars.partials.templateName is available when you use {{ > templateName }} within another template.

You can make them available by assigning them like so:

Handlebars.partials.templateName = MyPrecompiledTemplate

However you are defining your precompiled templates.