Permalink
Browse files

Better error when passing string to {{#each}}

Fixes #722
  • Loading branch information...
1 parent 4f4e534 commit 7e8c2f9405b4ce06a047878123cb0b0ce70e62c1 @avital avital committed Sep 24, 2013
Showing with 9 additions and 0 deletions.
  1. +9 −0 packages/templating/deftemplate.js
@@ -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))

0 comments on commit 7e8c2f9

Please sign in to comment.