Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame^] | 1 | ``empty`` |
| 2 | ========= |
| 3 | |
| 4 | ``empty`` checks if a variable is an empty string, an empty array, an empty |
| 5 | hash, exactly ``false``, or exactly ``null``. |
| 6 | |
| 7 | For objects that implement the ``Countable`` interface, ``empty`` will check the |
| 8 | return value of the ``count()`` method. |
| 9 | |
| 10 | For objects that implement the ``__toString()`` magic method (and not ``Countable``), |
| 11 | it will check if an empty string is returned. |
| 12 | |
| 13 | .. code-block:: twig |
| 14 | |
| 15 | {% if foo is empty %} |
| 16 | ... |
| 17 | {% endif %} |
| 18 | |