Does twig support the execution of multiple statements within the same {%%} block?
1 answer
You cannot execute multiple statements within a single block {% ... %}
, but the solution provided by CodeBrauer will do the trick. Anyway, keep in mind that the number of expressions to the left and right of the sign =
must be the same.
This means that if two (or three, etc.) variables have the same value, you must repeat that value. Example:
{# this will work as expected #}
{% set a, b, c = 'value', 'value', 'value' %}
{# this won't work #}
{% set a, b, c = 'value' %}
+2
source to share