I've a list of dictionaries and try to get an attribute of the last entry after a filter. The filtering is working but don't know how to get the attribute.
The template is:
{% set data = [{"key1":1},{"key1":2,"key2":"value"},{"key1":3}] %}
{% if data | selectattr("key1", "equalto", 2) | list %}
elem={{ data | selectattr("key1", "equalto", 2) | list | last }}
attr={{ data | selectattr("key1", "equalto", 2) | list | last | attr("key2") }}
{% endif %}
The output is:
elem={'key1': 2, 'key2': 'value'}
attr=