aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/template/twig/lexer.php
diff options
context:
space:
mode:
authorNathaniel Guse <nathaniel.guse@gmail.com>2013-07-19 13:08:41 -0500
committerNathaniel Guse <nathaniel.guse@gmail.com>2013-07-19 13:08:41 -0500
commitb92f660ed389414a1d8550a5ba92804f7151eb79 (patch)
tree6b2e682b8969f9de134c37bba9504ccdbc866f46 /phpBB/phpbb/template/twig/lexer.php
parent29322e85ff31d1a71a07846241dd809972323340 (diff)
downloadforums-b92f660ed389414a1d8550a5ba92804f7151eb79.tar
forums-b92f660ed389414a1d8550a5ba92804f7151eb79.tar.gz
forums-b92f660ed389414a1d8550a5ba92804f7151eb79.tar.bz2
forums-b92f660ed389414a1d8550a5ba92804f7151eb79.tar.xz
forums-b92f660ed389414a1d8550a5ba92804f7151eb79.zip
[ticket/11718] Twig lexer only correcting statements in IF, not ELSEIF
PHPBB3-11718
Diffstat (limited to 'phpBB/phpbb/template/twig/lexer.php')
-rw-r--r--phpBB/phpbb/template/twig/lexer.php9
1 files changed, 5 insertions, 4 deletions
diff --git a/phpBB/phpbb/template/twig/lexer.php b/phpBB/phpbb/template/twig/lexer.php
index 46412ad048..cb44de76f1 100644
--- a/phpBB/phpbb/template/twig/lexer.php
+++ b/phpBB/phpbb/template/twig/lexer.php
@@ -219,19 +219,20 @@ class phpbb_template_twig_lexer extends Twig_Lexer
{
$callback = function($matches)
{
+ $inner = $matches[2];
// Replace $TEST with definition.TEST
- $matches[1] = preg_replace('#\s\$([a-zA-Z_0-9]+)#', ' definition.$1', $matches[1]);
+ $inner = preg_replace('#\s\$([a-zA-Z_0-9]+)#', ' definition.$1', $inner);
// Replace .test with test|length
- $matches[1] = preg_replace('#\s\.([a-zA-Z_0-9\.]+)#', ' $1|length', $matches[1]);
+ $inner = preg_replace('#\s\.([a-zA-Z_0-9\.]+)#', ' $1|length', $inner);
- return '<!-- IF' . $matches[1] . '-->';
+ 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);
- return preg_replace_callback('#<!-- IF((.*)[\s][\$|\.|!]([^\s]+)(.*))-->#', $callback, $code);
+ return preg_replace_callback('#<!-- (ELSE)?IF((.*)[\s][\$|\.|!]([^\s]+)(.*))-->#', $callback, $code);
}
/**