Jinja Compat Tests

Enabled engines

groupby filter

Template

{% for type, items in items | groupby('type') %}
{{ type }}:
{% for item in items %}{{ item.name }} {% endfor %}
{% endfor %}

Data

{
  "items": [
    {
      "name": "james",
      "type": "green"
    },
    {
      "name": "john",
      "type": "blue"
    },
    {
      "name": "jim",
      "type": "blue"
    },
    {
      "name": "jessie",
      "type": "green"
    }
  ]
}

(error) v1.10.1

'for' statements should use the format 'for x in y': for type, items in items | groupby('type')

v2.8.0


blue:
john jim 

green:
james jessie 

(error) v3.0.6

Liquid syntax error: Syntax Error in 'for loop' - Valid syntax: for [item] in [collection]

v2.5.0


green:
james jessie 

blue:
john jim 

(error) v1.4.2

Invalid filter "groupby".

(error) v1.24.2

Unknown "groupby" filter.

(error) v0.9.5

Unable to find filter groupby