Skip to content

Commit

Permalink
Propagate options for client compiled partials
Browse files Browse the repository at this point in the history
Fixes #901
  • Loading branch information
kpdecker committed Nov 9, 2014
1 parent 4415f31 commit 4a2afa9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/handlebars/compiler/javascript-compiler.js
Expand Up @@ -145,6 +145,8 @@ JavaScriptCompiler.prototype = {
} else {
ret = ret.toString();
}
} else {
ret.compilerOptions = this.options;
}

return ret;
Expand Down
2 changes: 1 addition & 1 deletion lib/handlebars/runtime.js
Expand Up @@ -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) {
Expand Down
9 changes: 9 additions & 0 deletions spec/partials.js
Expand Up @@ -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}}";
Expand Down

0 comments on commit 4a2afa9

Please sign in to comment.