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.
To test for presence ("defined-ness"?), use is defined
.
To test that a present list is not empty, use the list itself as the condition.
While it doesn't seem to apply to your example, this form of the emptiness check is useful if you need something other than a loop.
An artificial example might be
{% if (texts is defined) and texts %}
The first text is {{ texts[0] }}
{% else %}
Error!
{% endif %}