Opened 13 years ago

Closed 13 years ago

#2146 closed enhancement (wontfix)

[patch] small change to built-in tag regroup

Reported by: Matias Hermanrud Fjeld Owned by: Adrian Holovaty
Component: Template system Version:
Severity: trivial Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


This patch makes the built-in tag regroup return group objects instead of dicts.
group objects are lists, but their str()-method returns the grouper.

This changes the syntax like so:

{{ group.grouped }} -> {{ group }}
{% for object in group.list %}... -> {% for object in group %}...

Thus one can write:

{% regroup something by attribute as groups %}
{% for group in groups %}
 <li>{{ group }}:
 {% for object in group %}
  {{ object }}
 {% endfor %}
{% endfor %}

The patch retains backwards compatability. One can still use the old syntax.

Attachments (1)

regroup.diff (3.0 KB) - added by Matias Hermanrud Fjeld <mhf@…> 13 years ago.

Download all attachments as: .zip

Change History (2)

Changed 13 years ago by Matias Hermanrud Fjeld <mhf@…>

Attachment: regroup.diff added

comment:1 Changed 13 years ago by Adrian Holovaty

Resolution: wontfix
Status: newclosed

This doesn't add a whole lot of value, so I'm marking as wontfix.

Note: See TracTickets for help on using tickets.
Back to Top