diff --git a/extra/cache-extra/Node/CacheNode.php b/extra/cache-extra/Node/CacheNode.php index de6d964fd..5cb73c592 100644 --- a/extra/cache-extra/Node/CacheNode.php +++ b/extra/cache-extra/Node/CacheNode.php @@ -40,7 +40,7 @@ class CacheNode extends AbstractExpression ->addDebugInfo($this) ->raw('$this->env->getRuntime(\'Twig\Extra\Cache\CacheRuntime\')->getCache()->get(') ->subcompile($this->getNode('key')) - ->raw(", function (\Symfony\Contracts\Cache\ItemInterface \$item) use (\$context, \$macros) {\n") + ->raw(", function (\Symfony\Contracts\Cache\ItemInterface \$item) use (\$context, \$macros, \$blocks) {\n") ->indent() ; diff --git a/src/Node/CaptureNode.php b/src/Node/CaptureNode.php index 534f1d01f..d7db218c3 100644 --- a/src/Node/CaptureNode.php +++ b/src/Node/CaptureNode.php @@ -24,7 +24,7 @@ class CaptureNode extends Node { public function __construct(Node $body, int $lineno, ?string $tag = null) { - parent::__construct(['body' => $body], ['raw' => false, 'with_blocks' => false], $lineno, $tag); + parent::__construct(['body' => $body], ['raw' => false], $lineno, $tag); } public function compile(Compiler $compiler): void @@ -34,13 +34,9 @@ class CaptureNode extends Node if (!$this->getAttribute('raw')) { $compiler->raw("('' === \$tmp = "); } - $compiler->raw($useYield ? "implode('', iterator_to_array(" : '\\Twig\\Extension\\CoreExtension::captureOutput('); - if ($this->getAttribute('with_blocks')) { - $compiler->raw("(function () use (&\$context, \$macros, \$blocks) {\n"); - } else { - $compiler->raw("(function () use (&\$context, \$macros) {\n"); - } $compiler + ->raw($useYield ? "implode('', iterator_to_array(" : '\\Twig\\Extension\\CoreExtension::captureOutput(') + ->raw("(function () use (&\$context, \$macros, \$blocks) {\n") ->indent() ->subcompile($this->getNode('body')) ->write("return; yield '';\n") diff --git a/src/Node/MacroNode.php b/src/Node/MacroNode.php index 761ef55d2..78e1b6f76 100644 --- a/src/Node/MacroNode.php +++ b/src/Node/MacroNode.php @@ -80,7 +80,6 @@ class MacroNode extends Node } $node = new CaptureNode($this->getNode('body'), $this->getNode('body')->lineno, $this->getNode('body')->tag); - $node->setAttribute('with_blocks', true); $compiler ->write('') diff --git a/src/Node/SetNode.php b/src/Node/SetNode.php index 6b4c873e1..0900f1542 100644 --- a/src/Node/SetNode.php +++ b/src/Node/SetNode.php @@ -38,7 +38,6 @@ class SetNode extends Node implements NodeCaptureInterface $capture = false; } else { $values = new CaptureNode($values, $values->getTemplateLine()); - $values->setAttribute('with_blocks', true); } }