Browse code

Bugfix: When rendering blocks of other templates, don't pass the local blocks array.

Alexander M. Turek authored on 18/11/2016 17:16:19
Showing 1 changed files
... ...
@@ -50,17 +50,17 @@ class Twig_Node_Expression_BlockReference extends Twig_Node_Expression
50 50
 
51 51
                 $this
52 52
                     ->compileTemplateCall($compiler)
53
-                    ->raw('->displayBlock(')
54
-                    ->subcompile($this->getNode('name'))
55
-                    ->raw(", \$context, \$blocks);\n")
53
+                    ->raw('->displayBlock')
56 54
                 ;
55
+                $this
56
+                    ->compileBlockArguments($compiler)
57
+                    ->raw(";\n");
57 58
             } else {
58 59
                 $this
59 60
                     ->compileTemplateCall($compiler)
60
-                    ->raw('->renderBlock(')
61
-                    ->subcompile($this->getNode('name'))
62
-                    ->raw(', $context, $blocks)')
61
+                    ->raw('->renderBlock')
63 62
                 ;
63
+                $this->compileBlockArguments($compiler);
64 64
             }
65 65
         }
66 66
     }
... ...
@@ -81,4 +81,18 @@ class Twig_Node_Expression_BlockReference extends Twig_Node_Expression
81 81
             ->raw(')')
82 82
         ;
83 83
     }
84
+
85
+    private function compileBlockArguments(Twig_Compiler $compiler)
86
+    {
87
+        $compiler
88
+            ->raw('(')
89
+            ->subcompile($this->getNode('name'))
90
+            ->raw(', $context');
91
+
92
+        if (!$this->hasNode('template')) {
93
+            $compiler->raw(', $blocks');
94
+        }
95
+
96
+        return $compiler->raw(')');
97
+    }
84 98
 }