In Twig I have operator is and test for empty variable (string or array):
{% if info is empty %}
...
{% endif %}
How I can do something like this in Swig template?
Simply do
{% if !info.length %}
...
{% endif %}
This will match strings (""
), arrays ([]
) and any other object which doesn't have a .length
property with truthy value.
{% if Object.keys(info).length != 0 %}
for an object/dict empty test
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With