From 534965078174773cdbc13e515737b9992a1e38c0 Mon Sep 17 00:00:00 2001 From: devojifr <44780880+devojifr@users.noreply.github.com> Date: Sat, 14 Oct 2023 11:22:02 +0200 Subject: [PATCH] range example leads to Array to string conversion exception In templates documentation, a range example is displayed and leads to an Array to string conversion exception without a join filter. --- doc/templates.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/templates.rst b/doc/templates.rst index d70fdbbe458..4ccfb8bb06f 100644 --- a/doc/templates.rst +++ b/doc/templates.rst @@ -752,11 +752,11 @@ The following operators don't fit into any of the other categories: (this is syntactic sugar for the :doc:`range` function): .. code-block:: twig - - {{ 1..5 }} + {# join filter is applied to avoid Array to string conversion exception #} + {{ (1..5)|join(', ') }} {# equivalent to #} - {{ range(1, 5) }} + {{ range(1, 5)|join(', ') }} Note that you must use parentheses when combining it with the filter operator due to the :ref:`operator precedence rules `: