Merge pull request #823 from fractal-surfing/with-inverse
Support inverse sections on the with helper
This commit is contained in:
@@ -185,6 +185,8 @@ function registerDefaultHelpers(instance) {
|
||||
}
|
||||
|
||||
return fn(context, options);
|
||||
} else {
|
||||
return options.inverse(this);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user