Support inverse sections on the with helper

This commit is contained in:
Dan Manges
2014-07-16 19:37:01 +00:00
parent 271106d43f
commit 2bdfd2a31d
2 changed files with 6 additions and 0 deletions
+2
View File
@@ -185,6 +185,8 @@ function registerDefaultHelpers(instance) {
}
return fn(context, options);
} else {
return options.inverse(this);
}
});
+4
View File
@@ -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() {