From 35456764a1ef25e453eb9387654a1c5bafe232dc Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Thu, 7 Aug 2014 10:45:33 -0700 Subject: [PATCH] Only pass indent through to standalone nested partials. Fixes #214 --- src/Mustache/Compiler.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Mustache/Compiler.php b/src/Mustache/Compiler.php index c6fa24d..e157e2e 100644 --- a/src/Mustache/Compiler.php +++ b/src/Mustache/Compiler.php @@ -277,9 +277,10 @@ class Mustache_Compiler return sprintf($this->prepare(self::INVERTED_SECTION, $level), $id, $method, $id, $filters, $this->walk($nodes, $level)); } + const PARTIAL_INDENT = ', $indent . %s'; const PARTIAL = ' if ($partial = $this->mustache->loadPartial(%s)) { - $buffer .= $partial->renderInternal($context, $indent . %s); + $buffer .= $partial->renderInternal($context%s); } '; @@ -294,10 +295,16 @@ class Mustache_Compiler */ private function partial($id, $indent, $level) { + if ($indent !== '') { + $indentParam = sprintf(self::PARTIAL_INDENT, var_export($indent, true)); + } else { + $indentParam = ''; + } + return sprintf( $this->prepare(self::PARTIAL, $level), var_export($id, true), - var_export($indent, true) + $indentParam ); }