Answers for "twig check if variables iterable"

0

twig check if variables iterable

{# evaluates to true if the foo variable is iterable #}
{% if users is iterable %}
    {% for user in users %}
        Hello {{ user }}!
    {% endfor %}
{% else %}
    {# users is probably a string #}
    Hello {{ users }}!
{% endif %}
Posted by: Guest on July-07-2021

Browse Popular Code Answers by Language