empty

empty checks if a variable is an empty string, an empty array, an empty hash, exactly false, or exactly null.

empty は、変数が空の文字列、空の配列、空のハッシュ、正確に false、または正確に null であるかどうかをチェックします。

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

Countable インターフェースを実装するオブジェクトの場合、空は count() メソッドの戻り値をチェックします。

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

__toString() マジック メソッドを実装する (および Countable ではない) オブジェクトの場合、空の文字列が返されるかどうかを確認します。
1
2
3
{% if foo is empty %}
    ...
{% endif %}