diff --git a/lib/handlebars/base.js b/lib/handlebars/base.js index 3cb432352..9b910c7f1 100644 --- a/lib/handlebars/base.js +++ b/lib/handlebars/base.js @@ -97,10 +97,8 @@ function registerDefaultHelpers(instance) { }); instance.registerHelper('each', function(context, options) { - // Allow for {{#each}} if (!options) { - options = context; - context = this; + throw new Exception('Must pass iterator to #each'); } var fn = options.fn, inverse = options.inverse; diff --git a/spec/builtins.js b/spec/builtins.js index bbe494e08..a28f40003 100644 --- a/spec/builtins.js +++ b/spec/builtins.js @@ -1,4 +1,4 @@ -/*global CompilerContext, shouldCompileTo, compileWithPartials, handlebarsEnv */ +/*global CompilerContext, shouldCompileTo, shouldThrow, compileWithPartials, handlebarsEnv */ describe('builtin helpers', function() { describe('#if', function() { it("if", function() { @@ -182,9 +182,10 @@ describe('builtin helpers', function() { }); 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!"); + shouldThrow(function() { + var template = CompilerContext.compile("{{#each}}{{text}}! {{/each}}cruel world!"); + template({}); + }, handlebarsEnv.Exception, 'Must pass iterator to #each'); }); });