Allow implicit context iteration with each

Fixes #671
This commit is contained in:
kpdecker
2014-01-17 20:13:00 -06:00
parent 363cb4b0fb
commit fe4880feaa
2 changed files with 11 additions and 0 deletions
+6
View File
@@ -80,6 +80,12 @@ function registerDefaultHelpers(instance) {
});
instance.registerHelper('each', function(context, options) {
// Allow for {{#each}}
if (!options) {
options = context;
context = this;
}
var fn = options.fn, inverse = options.inverse;
var i = 0, ret = "", data;
+5
View File
@@ -181,6 +181,11 @@ describe('builtin helpers', function() {
equal(result, 'a!b!c!', 'should output data');
});
it("each on implicit context", function() {
var string = "{{#each}}{{text}}! {{/each}}cruel world!";
var hash = [{text: "goodbye"}, {text: "Goodbye"}, {text: "GOODBYE"}];
shouldCompileTo(string, [hash], "goodbye! Goodbye! GOODBYE! cruel world!");
});
});
it("#log", function() {