So this will work:
{{ users|map(attribute="username", default="Anonymous")|join(", ") }}
but not this:
{{ users|map(attribute="username", default="")|join(", ") }}
For anyone else that happens to stumble over this: You may be able to use something like this as a workaround:
{{ users | map(attribute="username") | select("defined") | join(", ") }}
This works at least in Ansible (where the missing values resolve to AnsibleUndefined
), I haven't tested with pure Jinja2 though.
@davidism I am currently working on this Issue. Notified here.
Most helpful comment
@davidism I am currently working on this Issue. Notified here.