From 39ebd244e32230b42a873d3e9a7873ff96835d14 Mon Sep 17 00:00:00 2001 From: Niklas Liechti Date: Tue, 26 Nov 2019 19:39:12 +0100 Subject: [PATCH] Update playbooks_filters.rst (#64769) --- docs/docsite/rst/user_guide/playbooks_filters.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/docsite/rst/user_guide/playbooks_filters.rst b/docs/docsite/rst/user_guide/playbooks_filters.rst index 9ae246c1e3..d16f9e74fe 100644 --- a/docs/docsite/rst/user_guide/playbooks_filters.rst +++ b/docs/docsite/rst/user_guide/playbooks_filters.rst @@ -100,6 +100,10 @@ Jinja2 provides a useful 'default' filter that is often a better approach to fai In the above example, if the variable 'some_variable' is not defined, the value used will be 5, rather than an error being raised. + +Beginning in version 2.8, attempting to access an attribute of an Undefined value in Jinja will return another Undefined value, rather than throwing an error immediately. This means that you can now simply use +a default with a value in a nested data structure (i.e :code:`{{ foo.bar.baz | default('DEFAULT') }}`) when you don't know if the intermediate values are defined. + If you want to use the default value when variables evaluate to false or an empty string you have to set the second parameter to ``true``::