I need to check if the variable texts is defined or not in index.html.
texts
index.html
If the variable is defined and not empty then I should render the loop.
I think your best bet is a combination of defined() check along with looking at the length of the array via length() function:
{% if texts is defined and texts|length > 0 %} ... {% endif %}