Skip to content

Commit

Permalink
Merge branch 'laurie71-fix-issue-599'
Browse files Browse the repository at this point in the history
  • Loading branch information
kpdecker committed Oct 15, 2013
2 parents 9218f2e + 4fda713 commit 2cd0995
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/handlebars/compiler/javascript-compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ JavaScriptCompiler.prototype = {
var nextStack = this.nextStack();

this.source.push('if (' + nextStack + ' = ' + helperName + ') { ' + nextStack + ' = ' + nextStack + '.call(' + helper.callParams + '); }');
this.source.push('else { ' + nextStack + ' = ' + nonHelper + '; ' + nextStack + ' = typeof ' + nextStack + ' === functionType ? ' + nextStack + '.apply(depth0) : ' + nextStack + '; }');
this.source.push('else { ' + nextStack + ' = ' + nonHelper + '; ' + nextStack + ' = typeof ' + nextStack + ' === functionType ? ' + nextStack + '.call(depth0, options) : ' + nextStack + '; }');
},

// [invokePartial]
Expand Down
1 change: 1 addition & 0 deletions release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Compatibility notes:
- AMD: Users may load the bundled `handlebars.amd.js` or `handlebars.runtime.amd.js` files or load individual modules directly. AMD users should also note that the handlebars object is exposed via the `default` field on the imported object. This [gist](https://gist.github.com/wycats/7417be0dc361a69d5916) provides some discussion of possible compatibility shims.
- CommonJS/Node: Node loading occurs as normal via `require`
- Globals: The `handlebars.js` and `handlebars.runtime.js` files should behave in the same manner as the v1.0.12 / 1.0.0 release.
- Context-stored helpers are now always passed the `options` hash. Previously no-argument helpers did not have this argument.

[Commits](https://github.com/wycats/handlebars.js/compare/v1.0.12...master)

Expand Down
12 changes: 12 additions & 0 deletions spec/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,18 @@ describe("basic context", function() {
"Frank", "functions are called with context arguments");
});

it("block functions with context argument", function() {
shouldCompileTo("{{#awesome 1}}inner {{.}}{{/awesome}}",
{awesome: function(context, options) { return options.fn(context); }},
"inner 1", "block functions are called with context and options");
});

it("block functions without context argument", function() {
shouldCompileTo("{{#awesome}}inner{{/awesome}}",
{awesome: function(options) { return options.fn(this); }},
"inner", "block functions are called with options");
});


it("paths with hyphens", function() {
shouldCompileTo("{{foo-bar}}", {"foo-bar": "baz"}, "baz", "Paths can contain hyphens (-)");
Expand Down

0 comments on commit 2cd0995

Please sign in to comment.