From 0893a7d39d9ba4d009e01cd36e26ba71e3750667 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Sat, 22 May 2010 20:40:01 -0400 Subject: [PATCH] using array keys instead of iteration over context for creating subcontext arrays. this fixes incorrect context stacks in recursive partials. --- Mustache.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Mustache.php b/Mustache.php index 149fa11..bd81967 100644 --- a/Mustache.php +++ b/Mustache.php @@ -92,7 +92,6 @@ class Mustache { $this->_otag = '{{'; $this->_ctag = '}}'; $this->_localPragmas = null; - if ($keys = array_keys($this->_context)) { if ($this->_context[$keys[0]] instanceof Mustache) { $this->_context[$keys[0]] =& $this; @@ -475,8 +474,8 @@ class Mustache { protected function _pushContext(&$local_context) { $new = array(); $new[] =& $local_context; - foreach ($this->_context as $view) { - $new[] =& $view; + foreach (array_keys($this->_context) as $key) { + $new[] =& $this->_context[$key]; } $this->_context = $new; } @@ -491,9 +490,10 @@ class Mustache { protected function _popContext() { $new = array(); - array_shift($this->_context); - foreach ($this->_context as $view) { - $new[] =& $view; + $keys = array_keys($this->_context); + array_shift($keys); + foreach ($keys as $key) { + $new[] =& $this->_context[$key]; } $this->_context = $new; }