From f4f5c4d92aaa60991b565329621a0b9875cc2d03 Mon Sep 17 00:00:00 2001 From: Jiri Tyr Date: Mon, 13 Nov 2017 23:51:22 +0000 Subject: [PATCH] Documenting second parameter of the default filter (#31184) * Documenting second parameter of the default filter * Edited for clarity and grammar. * Adding missing colon --- docs/docsite/rst/playbooks_filters.rst | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/docsite/rst/playbooks_filters.rst b/docs/docsite/rst/playbooks_filters.rst index 651e7307948..dd18c6468e3 100644 --- a/docs/docsite/rst/playbooks_filters.rst +++ b/docs/docsite/rst/playbooks_filters.rst @@ -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: