# if\_undefined

Source: https://zotonic.com/docs/1846/if_undefined

URI: https://zotonic.com/id/1846

Language: en



Tests whether a value is undefined, returning the given argument.

Whereas the \|default filter also falls back to the default value when a value is an empty string or `false`, this filter only falls back to its value when the input value is the Erlang `undefined` atom.

This can be used for setting values which default to true if they are never set.

For example:

```django
{% if value|if_undefined:true %}The value is true or undefined{% endif %}
```

If the value is `undefined`, the output will be “The value is true or undefined”.

Alias for <a href="/id/doc_template_filter_filter_default_if_none" class="doc-reference doc-reference-filter"><code>filter#default_if_none</code></a>.

License: 

Attribution: 

Related resources: https://zotonic.com/api/agent/related/1846?language=en


## API access

- [API help](<https://zotonic.com/api-help>)
- [OpenAPI specification](<https://zotonic.com/openapi.json>)
- [This resource as JSON](<https://zotonic.com/api/agent/resource/1846?language=en>)
