added a note about using .. and | together

This commit is contained in:
Fabien Potencier
2015-10-12 09:39:52 +02:00
parent e624d0849e
commit 38029206d2
+18 -6
View File
@@ -771,15 +771,27 @@ Other Operators
.. versionadded:: 1.12.0
Support for the extended ternary operator was added in Twig 1.12.0.
The following operators are very useful but don't fit into any of the other
categories:
* ``..``: Creates a sequence based on the operand before and after the
operator (this is just syntactic sugar for the :doc:`range<functions/range>`
function).
The following operators don't fit into any of the other categories:
* ``|``: Applies a filter.
* ``..``: Creates a sequence based on the operand before and after the operator
(this is just syntactic sugar for the :doc:`range<functions/range>` function):
.. code-block:: jinja
{{ 1..5 }}
{# equivalent to #}
{{ range(1, 5) }}
Note that you must use parentheses when combining it with the filter operator
due to the :ref:`operator precedence rules <twig-expressions>`:
.. code-block:: jinja
(1..5)|join(', ')
* ``~``: Converts all operands into strings and concatenates them. ``{{ "Hello
" ~ name ~ "!" }}`` would return (assuming ``name`` is ``'John'``) ``Hello
John!``.