diff --git a/phpBB/phpbb/template/twig/lexer.php b/phpBB/phpbb/template/twig/lexer.php index 3534311b7a..a33de70d69 100644 --- a/phpBB/phpbb/template/twig/lexer.php +++ b/phpBB/phpbb/template/twig/lexer.php @@ -219,6 +219,12 @@ class phpbb_template_twig_lexer extends Twig_Lexer */ protected function fix_if_tokens($code) { + // Replace ELSE IF with ELSEIF + $code = preg_replace('##', '', $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]; @@ -234,9 +240,6 @@ class phpbb_template_twig_lexer extends Twig_Lexer return ""; }; - // 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); - return preg_replace_callback('##', $callback, $code); } diff --git a/tests/template/template_test.php b/tests/template/template_test.php index 15d75f09af..38eb072df8 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -62,6 +62,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array(), '1!false', ), + array( + 'if.html', + array('S_OTHER_OTHER_VALUE' => true), + array(), + array(), + '|S_OTHER_OTHER_VALUE|!false', + ), array( 'if.html', array('S_VALUE' => false, 'S_OTHER_VALUE' => true), diff --git a/tests/template/templates/if.html b/tests/template/templates/if.html index c010aff7fa..f6ab6e575a 100644 --- a/tests/template/templates/if.html +++ b/tests/template/templates/if.html @@ -2,6 +2,8 @@ 1 2 + +|S_OTHER_OTHER_VALUE| 03