we are using handlebars as template engine for a single page application framework and we have different applications. For each application we use grunt-contrib-handlebars to produce a different pre compiled handlebars file with its own partial inside. Something like..
app1 has node-templates-1.js app2 has node-templates-2.js and so on...
we use node.js as bootstrap to provide the app html to the client. So, inside the node app.js we have:
Handlebars = require('handlebars');
....
template1 = require('./path/node-templates-1.js')(Handlebars);
template2 = require('./path/node-templates-2.js')(Handlebars);
template3 = require('./path/node-templates-3.js')(Handlebars);
...
then, according to the application node is creating the html for we use template1 or template2 or whatever:
if(isApp1(...)) {
templateToUse = template1;
} else if(isApp2(..)) {
templateToUse = template2;
}
...
var html = renderer.getHTML(req.msRes, templateToUse , config, false);
...
Anyway, it doesn't work, it looks like binding a template to Handlebars caused some changes to the Handlebars object inner state so each template (template1, template2 ect) is equal to the last one we bound. Is there any way to make hanldebars work with different pre compiled files? thanks!