Propagate options for client compiled partials

Fixes #901
This commit is contained in:
kpdecker
2014-11-08 19:06:40 -06:00
parent 4415f3151d
commit 4a2afa9d02
3 changed files with 12 additions and 1 deletions
@@ -145,6 +145,8 @@ JavaScriptCompiler.prototype = {
} else {
ret = ret.toString();
}
} else {
ret.compilerOptions = this.options;
}
return ret;
+1 -1
View File
@@ -44,7 +44,7 @@ export function template(templateSpec, env) {
if (result == null && env.compile) {
var options = { helpers: helpers, partials: partials, data: data, depths: depths };
partials[name] = env.compile(partial, { data: data !== undefined, compat: templateSpec.compat }, env);
partials[name] = env.compile(partial, templateSpec.compilerOptions, env);
result = partials[name](context, options);
}
if (result != null) {
+9
View File
@@ -158,6 +158,15 @@ describe('partials', function() {
handlebarsEnv.compile = compile;
});
it('should pass compiler flags', function() {
if (Handlebars.compile) {
var env = Handlebars.create();
env.registerPartial('partial', '{{foo}}');
var template = env.compile('{{foo}} {{> partial}}', {noEscape: true});
equal(template({foo: '<'}), '< <');
}
});
describe('standalone partials', function() {
it("indented partials", function() {
var string = "Dudes:\n{{#dudes}}\n {{>dude}}\n{{/dudes}}";