Skip to content

Commit

Permalink
Better error when passing string to {{#each}}
Browse files Browse the repository at this point in the history
Fixes #722
  • Loading branch information
avital committed Sep 24, 2013
1 parent 4f4e534 commit 7e8c2f9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/templating/deftemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ var hookHandlebars = function () {

var orig = Handlebars._default_helpers.each;
Handlebars._default_helpers.each = function (arg, options) {
var isArgValid = function () {
return !arg // falsey
|| (arg instanceof Array)
|| (arg instanceof Object && 'observeChanges' in arg);
};
if (!isArgValid())
throw new Error("{{#each}} only accepts arrays, cursors, or falsey "
+ "values. You passed: " + arg);

// if arg isn't an observable (like LocalCollection.Cursor),
// don't use this reactive implementation of #each.
if (!(arg && 'observeChanges' in arg))
Expand Down

0 comments on commit 7e8c2f9

Please sign in to comment.