As in TWIG to check for the number of records in the database?

Before you run a cycle do I need to first validate:
If the records are many (more than 1) then print cycle, if less then too, we derive but a little different.
{% if records > 1 %} not roll))
How can I do that? something can't find.

An example of code that needs to be run if records for more than 1
{% if record %}

 <h2>{{ record.name }}</h2>

{% else %}
{% endif %}


Sample code to run if a record in one database.
{% if record %}

 <h1>{{ record.name }}</h1>

{% else %}
{% endif %}
June 10th 19 at 14:51
1 answer
June 10th 19 at 14:53
Solution
You may want to use the length filter:
{% if records|length > 1 %}
 {# print as list #}
{% else %}
 {# print as a single title #}
{% endif %}

Find more questions by tags Twig