jinja2 has a filter '| default () 'for working with undefined variables. But it does not work with dictionary values.
if D may or may not have the key foo (D [foo]), than:
{{ D[foo]|default ('no foo') }}
will print "no foo" if D is undefined, but will lead to an error (the "dict object" does not have the attribute "foo") if D is defined, but D [foo] is undefined.
Is there a way to make the default dictionary?
jinja2 ansible
George Shuklin Mar 05 '15 at 18:33 2015-03-05 18:33
source share