Question/Suggestion: Adding namespace for Handlebars
Closed this issue · 3 comments
cbmono commented
Hello,
I'm building a 3th. party application and I don't want to have Handlebars in the main namespace, because a different version might be already in use by the customer. Thus, I have something like window.MyApp = { Handlebars: {}, Templates: {}, ....}.
Is there a way to provide a namespace for Handlebars using grunt-contrib-handlebars?
Right now the output looks like:
this["MyApp"]["Templates"]["some_template"] = Handlebars.template(
function (Handlebars,depth0,helpers,partials,data) {...
Instead of 'MyApp.Handlebars':
this["MyApp"]["Templates"]["some_template"] = MyApp.Handlebars.template(
function (Handlebars,depth0,helpers,partials,data) {...
Thanks!
claudio.
cbmono commented
BTW, I'm achieving the wanted results using copy.options.processContent (https://github.com/gruntjs/grunt-contrib-handlebars#processcontent):
copy: {
templates: {
src: 'templates.js'
dest: 'templates.js'
options: {
processContent: (content, filepath) ->
content.replace /Handlebars\.template/mg, 'MyApp.Handlebars.template'
}
}
}
However, it would be still nice to have that option as part of grunt-contrib-handlebars, though.
jamesplease commented
PRs are welcome
jamesplease commented
Closed as duplicate of #69