diff --git a/extra/cache-extra/Node/CacheNode.php b/extra/cache-extra/Node/CacheNode.php index d6b438934..4600fa657 100644 --- a/extra/cache-extra/Node/CacheNode.php +++ b/extra/cache-extra/Node/CacheNode.php @@ -36,7 +36,7 @@ class CacheNode extends Node ->addDebugInfo($this) ->write('$cached = $this->env->getRuntime(\'Twig\Extra\Cache\CacheRuntime\')->getCache()->get(') ->subcompile($this->getNode('key')) - ->raw(", function (\Symfony\Contracts\Cache\ItemInterface \$item) use (\$context) {\n") + ->raw(", function (\Symfony\Contracts\Cache\ItemInterface \$item) use (\$context, \$macros) {\n") ->indent() ; diff --git a/extra/cache-extra/Tests/Fixtures/macro.test b/extra/cache-extra/Tests/Fixtures/macro.test new file mode 100644 index 000000000..4a8afb5cc --- /dev/null +++ b/extra/cache-extra/Tests/Fixtures/macro.test @@ -0,0 +1,22 @@ +--TEST-- +macro call inside "cache" tag +--TEMPLATE-- +{% macro macro_out(bar) %}{{ bar }}{% endmacro %} +1 +{% cache "testmacro1" ttl(3) %} + {%~ macro macro_in(bar) %}{{ bar }}{% endmacro %} + 2 + {{ _self.macro_out(3) }} + {{ _self.macro_in(4) }} +{% endcache %} +5 +{{ _self.macro_in(6) }} +--DATA-- +return [] +--EXPECT-- +1 + 2 + 3 + 4 +5 +6