소스 검색

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.
Justin Hileman 14 년 전
부모
커밋
392b0a3c57
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      Mustache.php

+ 1 - 1
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];
 			}
 		}