diff options
| author | Andreas Fischer <bantu@phpbb.com> | 2013-07-23 04:24:05 +0200 |
|---|---|---|
| committer | Andreas Fischer <bantu@phpbb.com> | 2013-07-23 04:24:05 +0200 |
| commit | 7d8e80241c43fa7d0ade4afa2f56d7eb1aa32989 (patch) | |
| tree | d80b5ec9b416c1f080273e59445a1f44e1634c6c | |
| parent | 1004aaf7877f26685992c89532725296ce7f64d0 (diff) | |
| parent | 1c59ad87b026794e44ce6c7561feabd3eb7bf165 (diff) | |
| download | forums-7d8e80241c43fa7d0ade4afa2f56d7eb1aa32989.tar forums-7d8e80241c43fa7d0ade4afa2f56d7eb1aa32989.tar.gz forums-7d8e80241c43fa7d0ade4afa2f56d7eb1aa32989.tar.bz2 forums-7d8e80241c43fa7d0ade4afa2f56d7eb1aa32989.tar.xz forums-7d8e80241c43fa7d0ade4afa2f56d7eb1aa32989.zip | |
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
| -rw-r--r-- | phpBB/phpbb/template/twig/lexer.php | 9 | ||||
| -rw-r--r-- | tests/template/template_test.php | 2 | ||||
| -rw-r--r-- | tests/template/templates/define.html | 5 |
3 files changed, 11 insertions, 5 deletions
diff --git a/phpBB/phpbb/template/twig/lexer.php b/phpBB/phpbb/template/twig/lexer.php index 1fa4c5b3e6..4f88147542 100644 --- a/phpBB/phpbb/template/twig/lexer.php +++ b/phpBB/phpbb/template/twig/lexer.php @@ -223,19 +223,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); } /** diff --git a/tests/template/template_test.php b/tests/template/template_test.php index 2ed0f03698..dd9ba21c26 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -151,7 +151,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array(), array('loop' => array(array(), array(), array(), array(), array(), array(), array()), 'test' => array(array()), 'test.deep' => array(array()), 'test.deep.defines' => array(array())), array(), - "xyz\nabc\nabc\nbar\nbar\nabc\ntest!@#$%^&*()_-=+{}[]:;\",<.>/?", + "xyz\nabc\n\$VALUE == 'abc'abc\nbar\nbar\nabc\ntest!@#$%^&*()_-=+{}[]:;\",<.>/?", ), array( 'define_advanced.html', diff --git a/tests/template/templates/define.html b/tests/template/templates/define.html index f0df16a8f8..66e874ca63 100644 --- a/tests/template/templates/define.html +++ b/tests/template/templates/define.html @@ -2,6 +2,11 @@ {$VALUE} <!-- DEFINE $VALUE = 'abc' --> {$VALUE} +<!-- IF $VALUE != 'abc' --> +$VALUE != 'abc' +<!-- ELSEIF $VALUE == 'abc' --> +$VALUE == 'abc' +<!-- ENDIF --> <!-- INCLUDE define_include.html --> {$INCLUDED_VALUE} {$VALUE} |
