diff --git a/lib/handlebars/base.js b/lib/handlebars/base.js index 9b910c7f..022417b4 100644 --- a/lib/handlebars/base.js +++ b/lib/handlebars/base.js @@ -185,6 +185,8 @@ function registerDefaultHelpers(instance) { } return fn(context, options); + } else { + return options.inverse(this); } }); diff --git a/spec/builtins.js b/spec/builtins.js index a28f4000..77f37012 100644 --- a/spec/builtins.js +++ b/spec/builtins.js @@ -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() {