!!! note This post is a thought. It's a short note that I make about someone else's content online. Learn more about the process here

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