minor #1869 added a note about using .. and | together (fabpot)

This PR was merged into the 1.x branch.

Discussion
----------

added a note about using .. and | together

fixes #1860

Commits
-------

3802920 added a note about using .. and | together
This commit is contained in:
Fabien Potencier
2015-10-13 09:01:13 +02:00
+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!``.