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

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

Show some equivalent list comprehensions in filter examples · Issue #1068 · pallets/jinja
I'm willing to write a pull-request for this, but I just want to see what people think before I write it. So the issue is this. I'm very familiar with python. I'm new to Jinja2. Often I find myself...
GitHub · github.com

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

Connections

Related tags and posts connected to this entry.