From eb1a8965695dc942c17bd114e46647ea53f877b1 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Sat, 22 May 2010 22:42:54 -0400 Subject: [PATCH] Fixed root context swap in clone (was checking context[0], should have checked last element in context stack). --- Mustache.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Mustache.php b/Mustache.php index bd81967..79b101d 100644 --- a/Mustache.php +++ b/Mustache.php @@ -92,9 +92,11 @@ 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; + $last = array_pop($keys); + if ($this->_context[$last] instanceof Mustache) { + $this->_context[$last] =& $this; } } }