mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
Merge remote-tracking branch 'EXreaction/ticket/11718' into develop
* EXreaction/ticket/11718: [ticket/11718] Quick test for fixes in ELSEIF [ticket/11718] Twig lexer only correcting statements in IF, not ELSEIF Conflicts: tests/template/template_test.php
This commit is contained in:
commit
7d8e80241c
3 changed files with 11 additions and 5 deletions
|
@ -223,19 +223,20 @@ class phpbb_template_twig_lexer extends Twig_Lexer
|
||||||
{
|
{
|
||||||
$callback = function($matches)
|
$callback = function($matches)
|
||||||
{
|
{
|
||||||
|
$inner = $matches[2];
|
||||||
// Replace $TEST with definition.TEST
|
// 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
|
// 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)
|
// 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);
|
$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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -151,7 +151,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
|
||||||
array(),
|
array(),
|
||||||
array('loop' => array(array(), array(), array(), array(), array(), array(), array()), 'test' => array(array()), 'test.deep' => array(array()), 'test.deep.defines' => array(array())),
|
array('loop' => array(array(), array(), array(), array(), array(), array(), array()), 'test' => array(array()), 'test.deep' => array(array()), 'test.deep.defines' => array(array())),
|
||||||
array(),
|
array(),
|
||||||
"xyz\nabc\nabc\nbar\nbar\nabc\ntest!@#$%^&*()_-=+{}[]:;\",<.>/?",
|
"xyz\nabc\n\$VALUE == 'abc'abc\nbar\nbar\nabc\ntest!@#$%^&*()_-=+{}[]:;\",<.>/?",
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'define_advanced.html',
|
'define_advanced.html',
|
||||||
|
|
|
@ -2,6 +2,11 @@
|
||||||
{$VALUE}
|
{$VALUE}
|
||||||
<!-- DEFINE $VALUE = 'abc' -->
|
<!-- DEFINE $VALUE = 'abc' -->
|
||||||
{$VALUE}
|
{$VALUE}
|
||||||
|
<!-- IF $VALUE != 'abc' -->
|
||||||
|
$VALUE != 'abc'
|
||||||
|
<!-- ELSEIF $VALUE == 'abc' -->
|
||||||
|
$VALUE == 'abc'
|
||||||
|
<!-- ENDIF -->
|
||||||
<!-- INCLUDE define_include.html -->
|
<!-- INCLUDE define_include.html -->
|
||||||
{$INCLUDED_VALUE}
|
{$INCLUDED_VALUE}
|
||||||
{$VALUE}
|
{$VALUE}
|
||||||
|
|
Loading…
Add table
Reference in a new issue