mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-26 05:08:52 +00:00
Merge remote-tracking branch 'EXreaction/ticket/11707' into develop
* EXreaction/ticket/11707: [ticket/11707] Twig DEFINE not working as expected
This commit is contained in:
commit
8efca016fa
3 changed files with 11 additions and 5 deletions
|
@ -126,10 +126,14 @@ class phpbb_template_twig_lexer extends Twig_Lexer
|
||||||
{
|
{
|
||||||
$callback = function($matches)
|
$callback = function($matches)
|
||||||
{
|
{
|
||||||
// Remove any quotes that may have been used in different implementations
|
// Remove matching quotes at the beginning/end if a statement;
|
||||||
// E.g. DEFINE $TEST = 'blah' vs INCLUDE foo
|
// E.g. 'asdf'"' -> asdf'"
|
||||||
// Replace {} with start/end to parse variables (' ~ TEST ~ '.html)
|
// E.g. "asdf'"" -> asdf'"
|
||||||
$matches[2] = str_replace(array('"', "'", '{', '}'), array('', '', "' ~ ", " ~ '"), $matches[2]);
|
// E.g. 'asdf'" -> 'asdf'"
|
||||||
|
$matches[2] = preg_replace('#^([\'"])?(.+?)\1$#', '$2', $matches[2]);
|
||||||
|
|
||||||
|
// Replace template variables with start/end to parse variables (' ~ TEST ~ '.html)
|
||||||
|
$matches[2] = preg_replace('#{([a-zA-Z0-9_\.$]+)}#', "'~ \$1 ~'", $matches[2]);
|
||||||
|
|
||||||
// Surround the matches in single quotes ('' ~ TEST ~ '.html')
|
// Surround the matches in single quotes ('' ~ TEST ~ '.html')
|
||||||
return "<!-- {$matches[1]} '{$matches[2]}' -->";
|
return "<!-- {$matches[1]} '{$matches[2]}' -->";
|
||||||
|
|
|
@ -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",
|
"xyz\nabc\nabc\nbar\nbar\nabc\ntest!@#$%^&*()_-=+{}[]:;\",<.>/?",
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'define_advanced.html',
|
'define_advanced.html',
|
||||||
|
|
|
@ -7,3 +7,5 @@
|
||||||
{$VALUE}
|
{$VALUE}
|
||||||
<!-- UNDEFINE $VALUE -->
|
<!-- UNDEFINE $VALUE -->
|
||||||
{$VALUE}
|
{$VALUE}
|
||||||
|
<!-- DEFINE $VALUE = 'test!@#$%^&*()_-=+{}[]:;",<.>/?' -->
|
||||||
|
{$VALUE}
|
||||||
|
|
Loading…
Add table
Reference in a new issue