Advertisement

Your Ad could be here. I want to connect my readers to relavant ads. If you have a product targeted at developers, let's talk. [email protected]

Here's my thought on Show some equivalent list comprehensions in filter examples · Issue #1068 · pallets/jinja


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 }} 

This post was a thought by Waylon Walker see all my thoughts at https://waylonwalker.com/thoughts