mirror of
https://github.com/twigphp/Twig.git
synced 2026-08-31 04:27:00 +00:00
Allow macro calls and definition inside cache tag
This commit is contained in:
@@ -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()
|
||||
;
|
||||
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user