1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-04-20 07:42:09 +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
commit 9d6370751f
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);
}

View File

@ -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),

View File

@ -2,6 +2,8 @@
1
<!-- ELSEIF S_OTHER_VALUE -->
2
<!-- ELSE IF S_OTHER_OTHER_VALUE -->
|S_OTHER_OTHER_VALUE|
<!-- ELSE -->
03
<!-- ENDIF -->