Check whether context item is an array before using it.

Fixes #24. This will be necessary once implicit iterators make it into production. It will also save people from themselves if they put an iterable array where Mustache expects to find a context.
This commit is contained in:
Justin Hileman
2011-03-01 11:41:13 -05:00
parent 6eb3ea0c8b
commit 392b0a3c57
+1 -1
View File
@@ -719,7 +719,7 @@ class Mustache {
} else if (isset($view->$tag_name)) { } else if (isset($view->$tag_name)) {
return $view->$tag_name; return $view->$tag_name;
} }
} else if (array_key_exists($tag_name, $view)) { } else if (is_array($view) && array_key_exists($tag_name, $view)) {
return $view[$tag_name]; return $view[$tag_name];
} }
} }