Edit on GitHub
Jump to docs navigation

Twig Components / Methods / empty

Note: You are currently reading the documentation for Bolt 5.0. Looking for the documentation for Bolt 5.2 instead?

empty is a Twig test check if a variable is an empty string, an empty array, an empty hash, exactly false, or exactly null.

For objects that implement the Countable interface, empty will check the return value of the count() method.

For objects that implement the __toString() magic method (and not Countable), it will check if an empty string is returned.

{% if foo is empty %}
    ...
{% endif %}

Source: Twig



Edit this page on GitHub
Couldn't find what you were looking for? We are happy to help you in the forum, on Slack or on Github.