diff options
| author | Joas Schilling <nickvergessen@gmx.de> | 2014-05-03 00:21:50 +0200 |
|---|---|---|
| committer | Joas Schilling <nickvergessen@gmx.de> | 2014-05-03 00:21:50 +0200 |
| commit | a995f1166c7c58ef2ae1f3474c4c1674110fab5e (patch) | |
| tree | 016054bc073c188924457ab098e9b61bf54bc264 /phpBB/phpbb | |
| parent | 1399d60954b484ac5ee0c9aca09b9a6221c04de0 (diff) | |
| parent | c5660ed177d05cd1139546833b2888115ec15ce8 (diff) | |
| download | forums-a995f1166c7c58ef2ae1f3474c4c1674110fab5e.tar forums-a995f1166c7c58ef2ae1f3474c4c1674110fab5e.tar.gz forums-a995f1166c7c58ef2ae1f3474c4c1674110fab5e.tar.bz2 forums-a995f1166c7c58ef2ae1f3474c4c1674110fab5e.tar.xz forums-a995f1166c7c58ef2ae1f3474c4c1674110fab5e.zip | |
Merge pull request #2391 from naderman/ticket/12382
[ticket/12382] Allow nested loops in included files.
Diffstat (limited to 'phpBB/phpbb')
| -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); } /** |
