1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 21:40:43 +02:00

Merge remote-tracking branch 'EXreaction/ticket/11724' into develop

* EXreaction/ticket/11724:
  [ticket/11724] Handle ELSE IF separately
  [ticket/11724] Replace spaces with tabs
  [ticket/11724] Support "ELSE IF" and "ELSEIF" in the same way
This commit is contained in:
Joas Schilling
2013-08-30 19:53:54 +02:00
3 changed files with 15 additions and 3 deletions

View File

@@ -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('#<!-- 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];
@@ -234,9 +240,6 @@ 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);
return preg_replace_callback('#<!-- (ELSE)?IF((.*)[\s][\$|\.|!]([^\s]+)(.*))-->#', $callback, $code);
}