Closed codegoat closed 9 years ago
Here is an example of what I mean, I took the partials_use_namespace test and modified it to add another template file.
partials_use_namespace: {
options: {
partialsUseNamespace: true
},
files: {
'tmp/partials_use_namespace.js': ['test/fixtures/has-spaces.hbs', 'test/fixtures/_partial.hbs', 'test/fixtures/one.hbs']
}
},
Which generates this:
Handlebars.registerPartial("partial", this["JST"]["partial"] = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
return "<span>Canada</span>";
},"useData":true}));
this["JST"] = this["JST"] || {};
this["JST"]["test/fixtures/has-spaces.hbs"] = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
return "\n\n <div>\n <span>this template has many spaces</span>\n </div>\n";
},"useData":true});
this["JST"]["test/fixtures/one.hbs"] = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, buffer = "<p>Hello, my name is "
+ escapeExpression(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"name","hash":{},"data":data}) : helper)))
+ ". I live in ";
stack1 = this.invokePartial(partials.partial, '', 'partial', depth0, undefined, helpers, partials, data);
if (stack1 != null) { buffer += stack1; }
return buffer + "</p>";
},"usePartial":true,"useData":true});
After the changes made in this PR, this is the result:
this["JST"] = this["JST"] || {};
Handlebars.registerPartial("partial", this["JST"]["partial"] = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
return "<span>Canada</span>";
},"useData":true}));
this["JST"] = this["JST"] || {};
this["JST"]["test/fixtures/has-spaces.hbs"] = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
return "\n\n <div>\n <span>this template has many spaces</span>\n </div>\n";
},"useData":true});
this["JST"]["test/fixtures/one.hbs"] = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, buffer = "<p>Hello, my name is "
+ escapeExpression(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"name","hash":{},"data":data}) : helper)))
+ ". I live in ";
stack1 = this.invokePartial(partials.partial, '', 'partial', depth0, undefined, helpers, partials, data);
if (stack1 != null) { buffer += stack1; }
return buffer + "</p>";
},"usePartial":true,"useData":true});
@codegoat Can you check 0.9.3 for this issue still? We merged in some of my changes and it resolved the issues for me. If so, please close this PR.
Since the 0.9 update, I have seen an issue where the partials are being output before the namespace, and because I am using the option partialsUseNameSpace: true, when the partials are output:
I am not very familiar with this project so I may not be taking other things into consideration with my change, but see the attached PR, it tracks the nsDeclarations separately between the partials and templates.