mirror of
https://github.com/twigphp/Twig.git
synced 2026-08-30 20:16:45 +00:00
tweaked docs
This commit is contained in:
+11
-3
@@ -11,11 +11,22 @@ function. The arrow function receives the value of the sequence or mapping:
|
||||
|
||||
{% set sizes = [34, 36, 38, 40, 42] %}
|
||||
|
||||
{{ sizes|filter(v => v > 38)|join(', ') }}
|
||||
{# output 40, 42 #}
|
||||
|
||||
Combined with the ``for`` tag, it allows to filter the itemss to iterate over:
|
||||
|
||||
.. code-block:: twig
|
||||
|
||||
{% for v in sizes|filter(v => v > 38) -%}
|
||||
{{ v }}
|
||||
{% endfor %}
|
||||
{# output 40 42 #}
|
||||
|
||||
It also works with mappings:
|
||||
|
||||
.. code-block:: twig
|
||||
|
||||
{% set sizes = {
|
||||
xs: 34,
|
||||
s: 36,
|
||||
@@ -29,9 +40,6 @@ function. The arrow function receives the value of the sequence or mapping:
|
||||
{% endfor %}
|
||||
{# output l = 40 xl = 42 #}
|
||||
|
||||
{{ sizes|filter(v => v > 38)|join(', ') }}
|
||||
{# output 40, 42 #}
|
||||
|
||||
The arrow function also receives the key as a second argument:
|
||||
|
||||
.. code-block:: twig
|
||||
|
||||
Reference in New Issue
Block a user