]> git.immae.eu Git - github/wallabag/wallabag.git/blob - vendor/twig/twig/doc/functions/range.rst
twig implementation
[github/wallabag/wallabag.git] / vendor / twig / twig / doc / functions / range.rst
1 ``range``
2 =========
3
4 Returns a list containing an arithmetic progression of integers:
5
6 .. code-block:: jinja
7
8 {% for i in range(0, 3) %}
9 {{ i }},
10 {% endfor %}
11
12 {# returns 0, 1, 2, 3 #}
13
14 When step is given (as the third parameter), it specifies the increment (or
15 decrement):
16
17 .. code-block:: jinja
18
19 {% for i in range(0, 6, 2) %}
20 {{ i }},
21 {% endfor %}
22
23 {# returns 0, 2, 4, 6 #}
24
25 The Twig built-in ``..`` operator is just syntactic sugar for the ``range``
26 function (with a step of 1):
27
28 .. code-block:: jinja
29
30 {% for i in 0..3 %}
31 {{ i }},
32 {% endfor %}
33
34 .. tip::
35
36 The ``range`` function works as the native PHP `range`_ function.
37
38 Arguments
39 ---------
40
41 * ``low``: The first value of the sequence.
42 * ``high``: The highest possible value of the sequence.
43 * ``step``: The increment between elements of the sequence.
44
45 .. _`range`: http://php.net/range