📜  twig 检查变量是否可迭代 - 无论代码示例

📅  最后修改于: 2022-03-11 14:55:00.595000             🧑  作者: Mango

代码示例1
{# 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 %}