Pārlūkot izejas kodu

Only pass indent through to standalone nested partials.

Fixes #214
Justin Hileman 11 gadi atpakaļ
vecāks
revīzija
35456764a1
1 mainītis faili ar 9 papildinājumiem un 2 dzēšanām
  1. 9 2
      src/Mustache/Compiler.php

+ 9 - 2
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
         );
     }