Skip to content

Commit

Permalink
Merge pull request #823 from fractal-surfing/with-inverse
Browse files Browse the repository at this point in the history
Support inverse sections on the with helper
  • Loading branch information
kpdecker committed Jul 29, 2014
2 parents 271106d + 2bdfd2a commit f374939
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/handlebars/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ function registerDefaultHelpers(instance) {
}

return fn(context, options);
} else {
return options.inverse(this);
}
});

Expand Down
4 changes: 4 additions & 0 deletions spec/builtins.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ describe('builtin helpers', function() {
var string = "{{#with person}}{{first}} {{last}}{{/with}}";
shouldCompileTo(string, {person: function() { return {first: "Alan", last: "Johnson"};}}, "Alan Johnson");
});
it("with with else", function() {
var string = "{{#with person}}Person is present{{else}}Person is not present{{/with}}";
shouldCompileTo(string, {}, "Person is not present");
});
});

describe('#each', function() {
Expand Down

0 comments on commit f374939

Please sign in to comment.