From 392b0a3c5701fcfdf9849e5d6877fe0319671c14 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Tue, 1 Mar 2011 11:41:13 -0500 Subject: [PATCH] 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. --- Mustache.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mustache.php b/Mustache.php index 34c5e15..7171acd 100644 --- a/Mustache.php +++ b/Mustache.php @@ -719,7 +719,7 @@ class Mustache { } else if (isset($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]; } }