Skip to content

Latest commit

 

History

History
32 lines (21 loc) · 726 Bytes

default.md

File metadata and controls

32 lines (21 loc) · 726 Bytes
layout title
page
Filters › default

← filters

Filter default(default, boolean):

  • default: The default value
  • boolean: Cast the value to boolean (default: false)

The default filter returns the passed default value if the value is undefined or empty, otherwise the value of the variable:

{{ var|default('var is not defined') }}

{{ var.foo|default('foo item on var is not defined') }}

{{ var['foo']|default('foo item on var is not defined') }}

If you want to use default with variables that evaluate to false you have to set the second parameter to true:

{{ ''|default('passed var is empty', true)  }}