diff options
author | Nils Adermann <naderman@naderman.de> | 2014-05-03 00:13:06 +0200 |
---|---|---|
committer | Nils Adermann <naderman@naderman.de> | 2014-05-03 00:13:06 +0200 |
commit | d18f19a3bbe764218f391932464e841b3f554c73 (patch) | |
tree | c3becb5caa6137c4438a7e59d184609ecb25f31c /phpBB/phpbb/template/twig/lexer.php | |
parent | 936518d201c5523ee71c5ee46f4415aa4bb9f4cf (diff) | |
download | forums-d18f19a3bbe764218f391932464e841b3f554c73.tar forums-d18f19a3bbe764218f391932464e841b3f554c73.tar.gz forums-d18f19a3bbe764218f391932464e841b3f554c73.tar.bz2 forums-d18f19a3bbe764218f391932464e841b3f554c73.tar.xz forums-d18f19a3bbe764218f391932464e841b3f554c73.zip |
[ticket/12382] Allow nested loops in included files.
They have to reference the fully qualified loop name in BEGIN and END.
PHPBB3-12382
Diffstat (limited to 'phpBB/phpbb/template/twig/lexer.php')
-rw-r--r-- | phpBB/phpbb/template/twig/lexer.php | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/phpBB/phpbb/template/twig/lexer.php b/phpBB/phpbb/template/twig/lexer.php index f4efc58540..49577f6e95 100644 --- a/phpBB/phpbb/template/twig/lexer.php +++ b/phpBB/phpbb/template/twig/lexer.php @@ -191,9 +191,16 @@ class lexer extends \Twig_Lexer $parent_class = $this; $callback = function ($matches) use ($parent_class, $parent_nodes) { - $name = $matches[1]; - $subset = trim(substr($matches[2], 1, -1)); // Remove parenthesis - $body = $matches[3]; + $hard_parents = explode('.', $matches[1]); + array_pop($hard_parents); // ends with . + if ($hard_parents) + { + $parent_nodes = array_merge($hard_parents, $parent_nodes); + } + + $name = $matches[2]; + $subset = trim(substr($matches[3], 1, -1)); // Remove parenthesis + $body = $matches[4]; // Replace <!-- BEGINELSE --> $body = str_replace('<!-- BEGINELSE -->', '{% else %}', $body); @@ -242,7 +249,7 @@ class lexer extends \Twig_Lexer return "{% for {$name} in {$parent}{$name}{$subset} %}{$body}{% endfor %}"; }; - return preg_replace_callback('#<!-- BEGIN ([!a-zA-Z0-9_]+)(\([0-9,\-]+\))? -->(.+?)<!-- END \1 -->#s', $callback, $code); + return preg_replace_callback('#<!-- BEGIN ((?:[a-zA-Z0-9_]+\.)*)([!a-zA-Z0-9_]+)(\([0-9,\-]+\))? -->(.+?)<!-- END \1\2 -->#s', $callback, $code); } /** |