mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-21 07:37:43 +00:00
changed default filter to use the empty test
This commit is contained in:
+11
-2
@@ -1263,11 +1263,20 @@ The ``..`` operator (see above) is a syntactic sugar for the ``range`` filter
|
||||
~~~~~~~~~~~
|
||||
|
||||
The ``default`` filter returns the passed default value if the value is
|
||||
undefined, otherwise the value of the variable:
|
||||
undefined or empty, otherwise the value of the variable:
|
||||
|
||||
.. code-block:: jinja
|
||||
|
||||
{{ my_variable|default('my_variable is not defined') }}
|
||||
{{ var|default('var is not defined') }}
|
||||
|
||||
{{ var.foo|default('foo item on var is not defined') }}
|
||||
|
||||
{{ ''|default('passed var is empty') }}
|
||||
|
||||
.. note::
|
||||
|
||||
Read the documentation for the ``defined`` and ``empty`` tests below to
|
||||
learn more about their semantics.
|
||||
|
||||
``keys``
|
||||
~~~~~~~~
|
||||
|
||||
Reference in New Issue
Block a user