@@ -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;
|
||||
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user