From cf39cfc5939f9407082f8f5c1f876ea0ee607a45 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Tue, 7 Oct 2014 20:51:08 +0200 Subject: [PATCH 1/2] [ticket/13132] Twig: Add loops content to the root context PHPBB3-13132 --- phpBB/phpbb/template/twig/twig.php | 6 + tests/template/template_test.php | 149 +++++++++++++++++- .../templates/loop_advanced_twig.html | 19 +++ .../template/templates/loop_expressions.html | 4 +- .../templates/loop_expressions_twig.html | 11 ++ .../templates/loop_include1_twig.html | 1 + .../template/templates/loop_include_twig.html | 4 + .../template/templates/loop_nested2_twig.html | 6 + .../loop_nested_deep_multilevel_ref_twig.html | 13 ++ .../templates/loop_nested_include1_twig.html | 5 + .../templates/loop_nested_include_twig.html | 4 + .../loop_nested_multilevel_ref_twig.html | 10 ++ .../template/templates/loop_nested_twig.html | 6 + tests/template/templates/loop_reuse_twig.html | 6 + tests/template/templates/loop_size_twig.html | 39 +++++ tests/template/templates/loop_twig.html | 21 +++ .../templates/loop_underscore_twig.html | 21 +++ tests/template/templates/loop_vars_twig.html | 13 ++ 18 files changed, 335 insertions(+), 3 deletions(-) create mode 100644 tests/template/templates/loop_advanced_twig.html create mode 100644 tests/template/templates/loop_expressions_twig.html create mode 100644 tests/template/templates/loop_include1_twig.html create mode 100644 tests/template/templates/loop_include_twig.html create mode 100644 tests/template/templates/loop_nested2_twig.html create mode 100644 tests/template/templates/loop_nested_deep_multilevel_ref_twig.html create mode 100644 tests/template/templates/loop_nested_include1_twig.html create mode 100644 tests/template/templates/loop_nested_include_twig.html create mode 100644 tests/template/templates/loop_nested_multilevel_ref_twig.html create mode 100644 tests/template/templates/loop_nested_twig.html create mode 100644 tests/template/templates/loop_reuse_twig.html create mode 100644 tests/template/templates/loop_size_twig.html create mode 100644 tests/template/templates/loop_twig.html create mode 100644 tests/template/templates/loop_underscore_twig.html create mode 100644 tests/template/templates/loop_vars_twig.html diff --git a/phpBB/phpbb/template/twig/twig.php b/phpBB/phpbb/template/twig/twig.php index 605d37e954..0e4c619029 100644 --- a/phpBB/phpbb/template/twig/twig.php +++ b/phpBB/phpbb/template/twig/twig.php @@ -352,6 +352,12 @@ class twig extends \phpbb\template\base // cleanup unset($vars['loops']['.']); + // Inject in the main context the value added by assign_block_vars() to be able to use directly the Twig loops. + foreach ($vars['loops'] as $key => &$value) + { + $vars[$key] = $value; + } + return $vars; } diff --git a/tests/template/template_test.php b/tests/template/template_test.php index bb6b7300cb..b67b49bd35 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -129,6 +129,34 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array(), "loop\nloop\nloop\nloop\nloop#0-block#0\nloop#0-block#1\nloop#1-block#0\nloop#1-block#1", ), + array( + 'loop_twig.html', + array(), + array(), + array(), + "noloop\nnoloop", + ), + array( + 'loop_twig.html', + array(), + array('test_loop' => array(array())), + array(), + "loop\nloop", + ), + array( + 'loop_twig.html', + array(), + array('test_loop' => array(array(), array()), 'test_loop.block' => array(array())), + array(), + "loop\nloop\nloop\nloop", + ), + array( + 'loop_twig.html', + array(), + array('test_loop' => array(array(), array()), 'test_loop.block' => array(array()), 'block' => array(array(), array())), + array(), + "loop\nloop\nloop\nloop\nloop#0-block#0\nloop#0-block#1\nloop#1-block#0\nloop#1-block#1", + ), array( 'loop_vars.html', array(), @@ -150,6 +178,27 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array(), "first\n0 - a\nx - b\nset\n1 - a\ny - b\nset\nlast\n0 - c\n1 - c\nlast inner", ), + array( + 'loop_vars_twig.html', + array(), + array('test_loop' => array(array('VARIABLE' => 'x'))), + array(), + "first\n0 - a\nx - b\nset\nlast", + ), + array( + 'loop_vars_twig.html', + array(), + array('test_loop' => array(array('VARIABLE' => 'x'), array('VARIABLE' => 'y'))), + array(), + "first\n0 - a\nx - b\nset\n1 - a\ny - b\nset\nlast", + ), + array( + 'loop_vars_twig.html', + array(), + array('test_loop' => array(array('VARIABLE' => 'x'), array('VARIABLE' => 'y')), 'test_loop.inner' => array(array(), array())), + array(), + "first\n0 - a\nx - b\nset\n1 - a\ny - b\nset\nlast\n0 - c\n1 - c\nlast inner", + ), array( 'loop_advanced.html', array(), @@ -157,6 +206,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array(), "101234561\nx\n101234561\nx\n101234561\nx\n1234561\nx\n1\nx\n101\nx\n234\nx\n10\nx\n561\nx\n561", ), + array( + 'loop_advanced_twig.html', + array(), + array('test_loop' => array(array(), array(), array(), array(), array(), array(), array())), + array(), + "101234561\nx\n101234561\nx\n101234561\nx\n1234561\nx\n1\nx\n101\nx\n234\nx\n10\nx\n561\nx\n561", + ), array( 'loop_nested2.html', array(), @@ -164,6 +220,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array(), "o0o1m01m11", ), + array( + 'loop_nested2_twig.html', + array(), + array('outer' => array(array(), array()), 'outer.middle' => array(array(), array())), + array(), + "o0o1m01m11", + ), array( 'define.html', array(), @@ -243,6 +306,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array('test_loop'), '', ), + array( + 'loop_vars_twig.html', + array(), + array('test_loop' => array(array('VARIABLE' => 'x'), array('VARIABLE' => 'y')), 'test_loop.inner' => array(array(), array())), + array('test_loop'), + '', + ), array( 'include_define_variable.html', array('VARIABLE' => 'variable.html'), @@ -274,6 +344,15 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array(), "noloop\nnoloop", ), + array( + // Just like a regular loop but the name begins + // with an underscore + 'loop_underscore_twig.html', + array(), + array(), + array(), + "noloop\nnoloop", + ), array( 'lang.html', array(), @@ -296,6 +375,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array(), "top-level content", ), + array( + 'loop_nested_multilevel_ref_twig.html', + array(), + array(), + array(), + "top-level content", + ), array( 'loop_nested_multilevel_ref.html', array(), @@ -303,6 +389,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array(), "top-level content\nouter x\nouter y\ninner z\nfirst row\n\ninner zz", ), + array( + 'loop_nested_multilevel_ref_twig.html', + array(), + array('outer' => array(array('VARIABLE' => 'x'), array('VARIABLE' => 'y')), 'outer.inner' => array(array('VARIABLE' => 'z'), array('VARIABLE' => 'zz'))), + array(), + "top-level content\nouter x\nouter y\ninner z\nfirst row\n\ninner zz", + ), array( 'loop_nested_deep_multilevel_ref.html', array(), @@ -310,6 +403,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array(), "top-level content\nouter\nmiddle\ninner z\nfirst row of 2 in inner\n\ninner zz", ), + array( + 'loop_nested_deep_multilevel_ref_twig.html', + array(), + array('outer' => array(array()), 'outer.middle' => array(array()), 'outer.middle.inner' => array(array('VARIABLE' => 'z'), array('VARIABLE' => 'zz'))), + array(), + "top-level content\nouter\nmiddle\ninner z\nfirst row of 2 in inner\n\ninner zz", + ), array( 'loop_size.html', array(), @@ -317,6 +417,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array(), "nonexistent = 0\n! nonexistent\n\nempty = 0\n! empty\nloop\n\nin loop", ), + array( + 'loop_size_twig.html', + array(), + array('test_loop' => array(array()), 'empty_loop' => array()), + array(), + "nonexistent = 0\n! nonexistent\n\nempty = 0\n! empty\nloop\n\nin loop", + ), array( 'loop_include.html', array(), @@ -324,6 +431,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array(), "barbarbar1bar1", ), + array( + 'loop_include_twig.html', + array(), + array('test_loop' => array(array('foo' => 'bar'), array('foo' => 'bar1'))), + array(), + "barbarbar1bar1", + ), array( 'loop_nested_include.html', array(), @@ -335,6 +449,17 @@ class phpbb_template_template_test extends phpbb_template_template_test_case "[bar|[bar|]][bar1|[bar1|[bar1|works]]]", array(), ), + array( + 'loop_nested_include_twig.html', + array(), + array( + 'test_loop' => array(array('foo' => 'bar'), array('foo' => 'bar1')), + 'test_loop.inner' => array(array('myinner' => 'works')), + ), + array(), + "[bar|[bar|]][bar1|[bar1|[bar1|works]]]", + array(), + ), /* Does not pass with the current implementation. array( 'loop_reuse.html', @@ -343,8 +468,15 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array(), // Not entirely sure what should be outputted but the current output of "a" is most certainly wrong "a\nb\nc\nd", + ),*/ + array( + 'loop_reuse_twig.html', + array(), + array('one' => array(array('VAR' => 'a'), array('VAR' => 'b')), 'one.one' => array(array('VAR' => 'c'), array('VAR' => 'd'))), + array(), + // Not entirely sure what should be outputted but the current output of "a" is most certainly wrong + "a\nb\nc\nd", ), - */ array( 'twig.html', array('VARIABLE' => 'FOObar',), @@ -359,6 +491,21 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array(), 'inner_value', ), + // Disable: needs Twig 1.14.2 + /*array( + 'loop_expressions.html', + array('loop' => array(array(),array(),array(),array(),array(),array()),), + array(), + array(), + 'yesnonoyesnonoyesnoyesnonoyes', + ), + array( + 'loop_expressions_twig.html', + array('loop' => array(array(),array(),array(),array(),array(),array()),), + array(), + array(), + 'yesnonoyesnonoyesnoyesnonoyes', + ),*/ ); } diff --git a/tests/template/templates/loop_advanced_twig.html b/tests/template/templates/loop_advanced_twig.html new file mode 100644 index 0000000000..fd9fcae045 --- /dev/null +++ b/tests/template/templates/loop_advanced_twig.html @@ -0,0 +1,19 @@ +{% for test_loop_inner in test_loop %}{{ test_loop_inner.S_FIRST_ROW }}{{ test_loop_inner.S_ROW_COUNT }}{{ test_loop_inner.S_LAST_ROW }}{% endfor %} +x +{% for test_loop_inner in test_loop|subset(0) %}{{ test_loop_inner.S_FIRST_ROW }}{{ test_loop_inner.S_ROW_COUNT }}{{ test_loop_inner.S_LAST_ROW }}{% endfor %} +x +{% for test_loop_inner in test_loop|subset(0,-1) %}{{ test_loop_inner.S_FIRST_ROW }}{{ test_loop_inner.S_ROW_COUNT }}{{ test_loop_inner.S_LAST_ROW }}{% endfor %} +x +{% for test_loop_inner in test_loop|subset(1) %}{{ test_loop_inner.S_FIRST_ROW }}{{ test_loop_inner.S_ROW_COUNT }}{{ test_loop_inner.S_LAST_ROW }}{% endfor %} +x +{% for test_loop_inner in test_loop|subset(1,1) %}{{ test_loop_inner.S_FIRST_ROW }}{{ test_loop_inner.S_ROW_COUNT }}{{ test_loop_inner.S_LAST_ROW }}{% endfor %} +x +{% for test_loop_inner in test_loop|subset(0,1) %}{{ test_loop_inner.S_FIRST_ROW }}{{ test_loop_inner.S_ROW_COUNT }}{{ test_loop_inner.S_LAST_ROW }}{% endfor %} +x +{% for test_loop_inner in test_loop|subset(2,4) %}{{ test_loop_inner.S_FIRST_ROW }}{{ test_loop_inner.S_ROW_COUNT }}{{ test_loop_inner.S_LAST_ROW }}{% endfor %} +x +{% for test_loop_inner in test_loop|subset(0,-7) %}{{ test_loop_inner.S_FIRST_ROW }}{{ test_loop_inner.S_ROW_COUNT }}{{ test_loop_inner.S_LAST_ROW }}{% endfor %} +x +{% for test_loop_inner in test_loop|subset(-2,6) %}{{ test_loop_inner.S_FIRST_ROW }}{{ test_loop_inner.S_ROW_COUNT }}{{ test_loop_inner.S_LAST_ROW }}{% endfor %} +x +{% for test_loop_inner in test_loop|subset(-2,-1) %}{{ test_loop_inner.S_FIRST_ROW }}{{ test_loop_inner.S_ROW_COUNT }}{{ test_loop_inner.S_LAST_ROW }}{% endfor %} diff --git a/tests/template/templates/loop_expressions.html b/tests/template/templates/loop_expressions.html index 6bff53f388..278bce1eca 100644 --- a/tests/template/templates/loop_expressions.html +++ b/tests/template/templates/loop_expressions.html @@ -1,11 +1,11 @@ -onoff +onoff -onoff +onoff diff --git a/tests/template/templates/loop_expressions_twig.html b/tests/template/templates/loop_expressions_twig.html new file mode 100644 index 0000000000..61a36c51e4 --- /dev/null +++ b/tests/template/templates/loop_expressions_twig.html @@ -0,0 +1,11 @@ +{% for loop_inner in loop %} + +{% if loop_inner.S_ROW_NUM is divisible by 4 %}on{% else %}off{% endif %} + +{% endfor %} + +{% for loop_inner in loop %} + +{% if loop_inner.S_ROW_NUM is divisible by 3 %}on{% else %}off{% endif %} + +{% endfor %} diff --git a/tests/template/templates/loop_include1_twig.html b/tests/template/templates/loop_include1_twig.html new file mode 100644 index 0000000000..2ff9f61b02 --- /dev/null +++ b/tests/template/templates/loop_include1_twig.html @@ -0,0 +1 @@ +{{ test_loop_inner.foo }} diff --git a/tests/template/templates/loop_include_twig.html b/tests/template/templates/loop_include_twig.html new file mode 100644 index 0000000000..1a534e2dbc --- /dev/null +++ b/tests/template/templates/loop_include_twig.html @@ -0,0 +1,4 @@ +{% for test_loop_inner in test_loop %} + {{ test_loop_inner.foo }} + {% INCLUDE 'loop_include1_twig.html' %} +{% endfor %} diff --git a/tests/template/templates/loop_nested2_twig.html b/tests/template/templates/loop_nested2_twig.html new file mode 100644 index 0000000000..cf802dc69f --- /dev/null +++ b/tests/template/templates/loop_nested2_twig.html @@ -0,0 +1,6 @@ +{% for outer_inner in outer %} + o{{ outer_inner.S_ROW_COUNT }} + {% for middle in outer_inner.middle %} + m{{ middle.S_ROW_COUNT }}{{ outer_inner.S_ROW_COUNT }} + {% endfor %} +{% endfor %} diff --git a/tests/template/templates/loop_nested_deep_multilevel_ref_twig.html b/tests/template/templates/loop_nested_deep_multilevel_ref_twig.html new file mode 100644 index 0000000000..9bc68e6e2e --- /dev/null +++ b/tests/template/templates/loop_nested_deep_multilevel_ref_twig.html @@ -0,0 +1,13 @@ +top-level content +{% for outer_inner in outer %} + outer + {% for middle in outer_inner.middle %} + {{ middle.S_BLOCK_NAME }} + {% for inner in middle.inner %} + inner {{ inner.VARIABLE }} + {% if inner.S_FIRST_ROW %} + first row of {{ inner.S_NUM_ROWS }} in {{ inner.S_BLOCK_NAME }} + {% endif %} + {% endfor %} + {% endfor %} +{% endfor %} diff --git a/tests/template/templates/loop_nested_include1_twig.html b/tests/template/templates/loop_nested_include1_twig.html new file mode 100644 index 0000000000..4c2ebb5f15 --- /dev/null +++ b/tests/template/templates/loop_nested_include1_twig.html @@ -0,0 +1,5 @@ +[{{ test_loop_inner.foo }}| +{% for inner in test_loop_inner.inner %} + [{{ test_loop_inner.foo }}| + {{ inner.myinner }}] +{% endfor %}] diff --git a/tests/template/templates/loop_nested_include_twig.html b/tests/template/templates/loop_nested_include_twig.html new file mode 100644 index 0000000000..c92ac922d1 --- /dev/null +++ b/tests/template/templates/loop_nested_include_twig.html @@ -0,0 +1,4 @@ +{% for test_loop_inner in test_loop %} + [{{ test_loop_inner.foo }} + |{% INCLUDE 'loop_nested_include1_twig.html' %}] +{% endfor %} diff --git a/tests/template/templates/loop_nested_multilevel_ref_twig.html b/tests/template/templates/loop_nested_multilevel_ref_twig.html new file mode 100644 index 0000000000..336a57d0bc --- /dev/null +++ b/tests/template/templates/loop_nested_multilevel_ref_twig.html @@ -0,0 +1,10 @@ +top-level content +{% for outer_inner in outer %} + outer {{ outer_inner.VARIABLE }} + {% for inner in outer_inner.inner %} + inner {{ inner.VARIABLE }} + {% if inner.S_FIRST_ROW %} + first row + {% endif %} + {% endfor %} +{% endfor %} diff --git a/tests/template/templates/loop_nested_twig.html b/tests/template/templates/loop_nested_twig.html new file mode 100644 index 0000000000..b294226b3a --- /dev/null +++ b/tests/template/templates/loop_nested_twig.html @@ -0,0 +1,6 @@ +{% for outer_inner in outer %} +outer - {{ outer_inner.S_ROW_COUNT }}{% if outer_inner.VARIABLE %} - {{ outer_inner.VARIABLE }}{% endif %}{% if TEST_MORE %}[{{ outer_inner.S_BLOCK_NAME }}|{{ outer_inner.S_NUM_ROWS }}]{% endif %} +{% for middle in outer_inner.middle %} +middle - {{ middle.S_ROW_COUNT }}{% if middle.VARIABLE %} - {{ middle.VARIABLE }}{% endif %}{% if TEST_MORE %}[{{ middle.S_BLOCK_NAME }}|{{ middle.S_NUM_ROWS }}]{% endif %} +{% endfor %} +{% endfor %} diff --git a/tests/template/templates/loop_reuse_twig.html b/tests/template/templates/loop_reuse_twig.html new file mode 100644 index 0000000000..67452a737f --- /dev/null +++ b/tests/template/templates/loop_reuse_twig.html @@ -0,0 +1,6 @@ +{% for one_inner in one %} + {{ one_inner.VAR }} + {% for one_one_inner in one_inner.one %} + {{ one_one_inner.VAR }} + {% endfor %} +{% endfor %} diff --git a/tests/template/templates/loop_size_twig.html b/tests/template/templates/loop_size_twig.html new file mode 100644 index 0000000000..f6d2571e11 --- /dev/null +++ b/tests/template/templates/loop_size_twig.html @@ -0,0 +1,39 @@ +{% if nonexistent_loop|length %} +nonexistent +{% endif %} + +{% if nonexistent_loop|length == 0 %} +nonexistent = 0 +{% endif %} + +{% if ! nonexistent_loop|length %} +! nonexistent +{% endif %} + +{% if empty_loop|length %} +empty +{% endif %} + +{% if empty_loop|length == 0 %} +empty = 0 +{% endif %} + +{% if ! empty_loop|length %} +! empty +{% endif %} + +{% if test_loop|length %} +loop +{% endif %} + +{% if test_loop|length == 0 %} +loop = 0 +{% endif %} + +{% if ! test_loop|length %} +! loop +{% endif %} + +{% for test_loop_inner in test_loop %} +in loop +{% endfor %} diff --git a/tests/template/templates/loop_twig.html b/tests/template/templates/loop_twig.html new file mode 100644 index 0000000000..fb24f331b3 --- /dev/null +++ b/tests/template/templates/loop_twig.html @@ -0,0 +1,21 @@ +{% for test_loop_inner in test_loop %} +loop +{% else %} +noloop +{% endfor %} + +{% if test_loop|length %} +loop +{% else %} +noloop +{% endif %} + +{% if test_loop|length == 2 %} +loop +{% endif %} + +{% for test_loop_inner in test_loop %} +{% for block_inner in block %} +loop#{{ test_loop_inner.S_ROW_COUNT }}-block#{{ block_inner.S_ROW_COUNT }} +{% endfor %} +{% endfor %} diff --git a/tests/template/templates/loop_underscore_twig.html b/tests/template/templates/loop_underscore_twig.html new file mode 100644 index 0000000000..44b095c882 --- /dev/null +++ b/tests/template/templates/loop_underscore_twig.html @@ -0,0 +1,21 @@ +{% for _underscore_loop_inner in _underscore_loop %} +loop +{% else %} +noloop +{% endfor %} + +{% if _underscore_loop|length %} +loop +{% else %} +noloop +{% endif %} + +{% if _underscore_loop|length == 2 %} +loop +{% endif %} + +{% for _underscore_loop_inner in _underscore_loop %} +{% for block_inner in block %} +loop#{{ loop.S_ROW_COUNT }}-block#{{ block_inner.S_ROW_COUNT }} +{% endfor %} +{% endfor %} diff --git a/tests/template/templates/loop_vars_twig.html b/tests/template/templates/loop_vars_twig.html new file mode 100644 index 0000000000..af6c63d8e3 --- /dev/null +++ b/tests/template/templates/loop_vars_twig.html @@ -0,0 +1,13 @@ +{% for test_loop_inner in test_loop %} +{% if test_loop_inner.S_FIRST_ROW %}first{% endif %} +{{ test_loop_inner.S_ROW_NUM }} - a +{{ test_loop_inner.VARIABLE }} - b +{% if test_loop_inner.VARIABLE %}set{% endif %} +{% if test_loop_inner.S_LAST_ROW %} +last +{% endif %} +{% for inner_inner in test_loop_inner.inner %} +{{ inner_inner.S_ROW_NUM }} - c +{% if inner_inner.S_LAST_ROW and inner_inner.S_ROW_COUNT and inner_inner.S_NUM_ROWS %}last inner{% endif %} +{% endfor %} +{% endfor %} From 54753e926df28b686937394bc675130647893639 Mon Sep 17 00:00:00 2001 From: Nicofuma Date: Thu, 5 Mar 2015 21:53:48 +0100 Subject: [PATCH 2/2] [ticket/13132] Enable twig expressions tests PHPBB3-13132 --- tests/template/template_test.php | 18 ++++++++++++------ tests/template/templates/loop_expressions.html | 4 ++-- .../templates/loop_expressions_twig.html | 4 ++-- .../templates/loop_expressions_twig2.html | 11 +++++++++++ 4 files changed, 27 insertions(+), 10 deletions(-) create mode 100644 tests/template/templates/loop_expressions_twig2.html diff --git a/tests/template/template_test.php b/tests/template/template_test.php index b67b49bd35..33dc4ca551 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -491,21 +491,27 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array(), 'inner_value', ), - // Disable: needs Twig 1.14.2 - /*array( + array( 'loop_expressions.html', + array(), array('loop' => array(array(),array(),array(),array(),array(),array()),), array(), - array(), - 'yesnonoyesnonoyesnoyesnonoyes', + 'yesnononoyesnoyesnonoyesnono', ), array( 'loop_expressions_twig.html', + array(), + array('loop' => array(array(),array(),array(),array(),array(),array()),), + array(), + 'yesnononoyesnoyesnonoyesnono', + ), + array( + 'loop_expressions_twig2.html', array('loop' => array(array(),array(),array(),array(),array(),array()),), array(), array(), - 'yesnonoyesnonoyesnoyesnonoyes', - ),*/ + 'yesnononoyesnoyesnonoyesnono', + ), ); } diff --git a/tests/template/templates/loop_expressions.html b/tests/template/templates/loop_expressions.html index 278bce1eca..ddb9fd52fa 100644 --- a/tests/template/templates/loop_expressions.html +++ b/tests/template/templates/loop_expressions.html @@ -1,11 +1,11 @@ -onoff +yesno -onoff +yesno diff --git a/tests/template/templates/loop_expressions_twig.html b/tests/template/templates/loop_expressions_twig.html index 61a36c51e4..5ca8cc3601 100644 --- a/tests/template/templates/loop_expressions_twig.html +++ b/tests/template/templates/loop_expressions_twig.html @@ -1,11 +1,11 @@ {% for loop_inner in loop %} -{% if loop_inner.S_ROW_NUM is divisible by 4 %}on{% else %}off{% endif %} +{% if loop_inner.S_ROW_NUM is divisible by(4) %}yes{% else %}no{% endif %} {% endfor %} {% for loop_inner in loop %} -{% if loop_inner.S_ROW_NUM is divisible by 3 %}on{% else %}off{% endif %} +{% if loop_inner.S_ROW_NUM is divisible by(3) %}yes{% else %}no{% endif %} {% endfor %} diff --git a/tests/template/templates/loop_expressions_twig2.html b/tests/template/templates/loop_expressions_twig2.html new file mode 100644 index 0000000000..16159ead4c --- /dev/null +++ b/tests/template/templates/loop_expressions_twig2.html @@ -0,0 +1,11 @@ +{% for loop_inner in loop %} + +{% if loop.index0 is divisible by(4) %}yes{% else %}no{% endif %} + +{% endfor %} + +{% for loop_inner in loop %} + +{% if loop.index0 is divisible by(3) %}yes{% else %}no{% endif %} + +{% endfor %}