Twig if else语法

Twig if else语法,twig,Twig,当我的酒店空无一人时,如何使用tiwg语法打印“未找到” {% if hotels is empty %} <p>not found</p> {% else %} {% for hotel in hotels %} {% if %} {% else %} {% endif %} {% else %} {% endif %} 如果我的酒店是空的,它就没有找到酒店很

当我的酒店空无一人时,如何使用tiwg语法打印“未找到”

{% if hotels is empty %}
    <p>not found</p>
{% else %}
    {% for hotel in hotels %}                
        {% if  %}

        {% else %}

        {% endif %}
    {% else %}
{% endif %}
如果我的酒店是空的,它就没有找到

酒店很清楚地提到了它

试试这个

{% for hotel in hotels %}                
    {% if  %}

    {% else %}

    {% endif %}
{% else %}
    <p>not found</p>
{% endfor %}
感谢DarkBee的更正。

只需使用{%for hotels in hotels%}…{%else%}找不到酒店{%endfor%}