test131
test131

Reputation: 93

Twig if else syntax

How can I print not found when my hotel is empty using tiwg syntax

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

        {% else %}

        {% endif %}
    {% else %}
{% endif %}

if my hotels is empty it didnt not found

Upvotes: 0

Views: 291

Answers (1)

Vinh VO
Vinh VO

Reputation: 703

The twig doc of for loop mentions it very clearly.

Try this

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

    {% else %}

    {% endif %}
{% else %}
    <p>not found</p>
{% endfor %}

Thanks DarkBee for correcting me.

Upvotes: 1

Related Questions