I need to check if the variable texts
is defined or not in index.html
.
If the variable is defined and not empty then I should render the loop.
It's possible that texts
could be defined but contain a single list element which is an empty string; For example:
texts = ['']
In this case, testing if texts
is defined will produce a true result so you should test the first element instead:
{% if texts[0] != '' %}
..code here..
{% endif %}
You might also want to combine that with the |length
filter to make sure it only has one element.