aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/template/twig
diff options
context:
space:
mode:
authorNathan Guse <nathaniel.guse@gmail.com>2013-08-28 12:29:01 -0500
committerNathan Guse <nathaniel.guse@gmail.com>2013-08-28 12:29:01 -0500
commit38a7aac0cceee521fbf2550750a85b4d6bf80ec1 (patch)
tree8b8b2cb8f20a328318d6375036a1bfb970abba08 /phpBB/phpbb/template/twig
parent0215e0bd95104c628cf084e1be0df72b2752346c (diff)
downloadforums-38a7aac0cceee521fbf2550750a85b4d6bf80ec1.tar
forums-38a7aac0cceee521fbf2550750a85b4d6bf80ec1.tar.gz
forums-38a7aac0cceee521fbf2550750a85b4d6bf80ec1.tar.bz2
forums-38a7aac0cceee521fbf2550750a85b4d6bf80ec1.tar.xz
forums-38a7aac0cceee521fbf2550750a85b4d6bf80ec1.zip
[ticket/11724] Handle ELSE IF separately
PHPBB3-11724
Diffstat (limited to 'phpBB/phpbb/template/twig')
-rw-r--r--phpBB/phpbb/template/twig/lexer.php12
1 files changed, 7 insertions, 5 deletions
diff --git a/phpBB/phpbb/template/twig/lexer.php b/phpBB/phpbb/template/twig/lexer.php
index 7cb84167bf..d576316e89 100644
--- a/phpBB/phpbb/template/twig/lexer.php
+++ b/phpBB/phpbb/template/twig/lexer.php
@@ -221,6 +221,12 @@ class phpbb_template_twig_lexer extends Twig_Lexer
*/
protected function fix_if_tokens($code)
{
+ // Replace ELSE IF with ELSEIF
+ $code = preg_replace('#<!-- ELSE IF (.+?) -->#', '<!-- ELSEIF $1 -->', $code);
+
+ // Replace our "div by" with Twig's divisibleby (Twig does not like test names with spaces)
+ $code = preg_replace('# div by ([0-9]+)#', ' divisibleby($1)', $code);
+
$callback = function($matches)
{
$inner = $matches[2];
@@ -233,11 +239,7 @@ class phpbb_template_twig_lexer extends Twig_Lexer
return "<!-- {$matches[1]}IF{$inner}-->";
};
- // Replace our "div by" with Twig's divisibleby (Twig does not like test names with spaces)
- $code = preg_replace('# div by ([0-9]+)#', ' divisibleby($1)', $code);
-
- // (ELSE)?\s?IF; match IF|ELSEIF|ELSE IF; replace ELSE IF with ELSEIF
- return preg_replace_callback('#<!-- (ELSE)?\s?IF(.+?)-->#', $callback, $code);
+ return preg_replace_callback('#<!-- (ELSE)?IF((.*)[\s][\$|\.|!]([^\s]+)(.*))-->#', $callback, $code);
}
/**