def

Returns a given default value for a variable in case the variable is not defined or empty.

@{ variable | def (value) }

Parameters

value
The default value to be returned in case the variable is not defined or empty.

Example

The following example demonstrates a standard use case for providing a default value. Let's assume a pagelist is sorted by the query string paramter sort. In case there is no query string parameters defined, the list is sorted by date desc — in other words "recent first".

<@ newPagelist {  
  sort: @{ ?sort | def ('date desc') }
} @>
dateFormat escape