Tests
Test: attribute
Template
{% for item in items|selectattr('id', 'odd') %}
{{ item.name }}
{% endfor %}
Data
{
"items": [
{ "id": 1, "name": "alpha" },
{ "id": 2, "name": "bravo" },
{ "id": 3, "name": "delta" }
]
}
Output Django (error) v1.10.1
'for' statements should use the format 'for x in y': for item in items|selectattr('id', 'odd')
Output Jinja2 v2.8.0
alpha
delta
Output Liquid v3.0.6
alpha
bravo
delta
Output Nunjucks v2.5.0
alpha
bravo
delta
Output Swig (error) v1.4.2
Invalid filter "selectattr".
Output Twig (error) v1.24.2
Unknown "selectattr" filter.
Output Twigjs (error) v0.9.5
Unable to find filter selectattr
Test: default
Template
{% for item in items|selectattr('is_selected') %}
{{ item.name }}
{% endfor %}
Data
{
"items": [
{ "name": "alpha", "is_selected": false },
{ "name": "bravo", "is_selected": true },
{ "name": "delta", "is_selected": true }
]
}
Output Django (error) v1.10.1
Invalid filter: 'selectattr'
Output Jinja2 v2.8.0
bravo
delta
Output Liquid v3.0.6
alpha
bravo
delta
Output Nunjucks v2.5.0
bravo
delta
Output Swig (error) v1.4.2
Invalid filter "selectattr".
Output Twig (error) v1.24.2
Unknown "selectattr" filter.
Output Twigjs (error) v0.9.5
Unable to find filter selectattr