Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documenting second parameter of the default filter #31184

Merged
merged 3 commits into from
Nov 13, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion docs/docsite/rst/playbooks_filters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,18 @@ The variable value will be used as is, but the template evaluation will raise an
Defaulting Undefined Variables
``````````````````````````````

Jinja2 provides a useful 'default' filter, that is often a better approach to failing if a variable is not defined::
Jinja2 provides a useful 'default' filter that is often a better approach to failing if a variable is not defined::

{{ some_variable | default(5) }}

In the above example, if the variable 'some_variable' is not defined, the value used will be 5, rather than an error
being raised.

If the variable evaluates to an empty string, the second parameter of the filter should be set to
`true`::

{{ lookup('env', 'MY_USER') | default('admin', true) }}


.. _omitting_undefined_variables:

Expand Down