mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-31 22:10:45 +02:00
[ticket/13132] Twig: Add loops content to the root context
PHPBB3-13132
This commit is contained in:
committed by
Nicofuma
parent
70990bc86f
commit
cf39cfc593
19
tests/template/templates/loop_advanced_twig.html
Normal file
19
tests/template/templates/loop_advanced_twig.html
Normal file
@@ -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 %}
|
@@ -1,11 +1,11 @@
|
||||
<!-- BEGIN loop -->
|
||||
|
||||
<!-- IF loop.S_ROW_NUM is even by 4 -->on<!-- ELSE -->off<!-- ENDIF -->
|
||||
<!-- IF loop.S_ROW_NUM is divisible by 4 -->on<!-- ELSE -->off<!-- ENDIF -->
|
||||
|
||||
<!-- END loop -->
|
||||
|
||||
<!-- BEGIN loop -->
|
||||
|
||||
<!-- IF loop.S_ROW_NUM is odd by 3 -->on<!-- ELSE -->off<!-- ENDIF -->
|
||||
<!-- IF loop.S_ROW_NUM is divisible by 3 -->on<!-- ELSE -->off<!-- ENDIF -->
|
||||
|
||||
<!-- END loop -->
|
||||
|
11
tests/template/templates/loop_expressions_twig.html
Normal file
11
tests/template/templates/loop_expressions_twig.html
Normal file
@@ -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 %}
|
1
tests/template/templates/loop_include1_twig.html
Normal file
1
tests/template/templates/loop_include1_twig.html
Normal file
@@ -0,0 +1 @@
|
||||
{{ test_loop_inner.foo }}
|
4
tests/template/templates/loop_include_twig.html
Normal file
4
tests/template/templates/loop_include_twig.html
Normal file
@@ -0,0 +1,4 @@
|
||||
{% for test_loop_inner in test_loop %}
|
||||
{{ test_loop_inner.foo }}
|
||||
{% INCLUDE 'loop_include1_twig.html' %}
|
||||
{% endfor %}
|
6
tests/template/templates/loop_nested2_twig.html
Normal file
6
tests/template/templates/loop_nested2_twig.html
Normal file
@@ -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 %}
|
@@ -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 %}
|
5
tests/template/templates/loop_nested_include1_twig.html
Normal file
5
tests/template/templates/loop_nested_include1_twig.html
Normal file
@@ -0,0 +1,5 @@
|
||||
[{{ test_loop_inner.foo }}|
|
||||
{% for inner in test_loop_inner.inner %}
|
||||
[{{ test_loop_inner.foo }}|
|
||||
{{ inner.myinner }}]
|
||||
{% endfor %}]
|
4
tests/template/templates/loop_nested_include_twig.html
Normal file
4
tests/template/templates/loop_nested_include_twig.html
Normal file
@@ -0,0 +1,4 @@
|
||||
{% for test_loop_inner in test_loop %}
|
||||
[{{ test_loop_inner.foo }}
|
||||
|{% INCLUDE 'loop_nested_include1_twig.html' %}]
|
||||
{% endfor %}
|
@@ -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 %}
|
6
tests/template/templates/loop_nested_twig.html
Normal file
6
tests/template/templates/loop_nested_twig.html
Normal file
@@ -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 %}
|
6
tests/template/templates/loop_reuse_twig.html
Normal file
6
tests/template/templates/loop_reuse_twig.html
Normal file
@@ -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 %}
|
39
tests/template/templates/loop_size_twig.html
Normal file
39
tests/template/templates/loop_size_twig.html
Normal file
@@ -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 %}
|
21
tests/template/templates/loop_twig.html
Normal file
21
tests/template/templates/loop_twig.html
Normal file
@@ -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 %}
|
21
tests/template/templates/loop_underscore_twig.html
Normal file
21
tests/template/templates/loop_underscore_twig.html
Normal file
@@ -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 %}
|
13
tests/template/templates/loop_vars_twig.html
Normal file
13
tests/template/templates/loop_vars_twig.html
Normal file
@@ -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 %}
|
Reference in New Issue
Block a user