💭 Show some equivalent list comprehensions in filter examples · ...

!https://github.com/pallets/jinja/issues/1068

Copy this post

I often want to reach for non existing list comprehensions in jinja 2, Here are a few nice equivalents.

a: {{ data | selectattr('x', 'gt', 5) | list }}
b: {{ data | map(attribute='c') | list }} 
c: {{ data | selectattr('x', 'gt', 5) | map(attribute='c') | list }} 

Note

This post is a thought. It’s a short note that I make about someone else’s content online #thoughts