Opened 18 years ago

Closed 18 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

Description

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 %}
<ul>
{% for group in groups %}
 <li>{{ group }}:
 {% for object in group %}
  {{ object }}
 {% endfor %}
 </li>
{% endfor %}
</ul>

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@…> 18 years ago.

Download all attachments as: .zip

Change History (2)

by Matias Hermanrud Fjeld <mhf@…>, 18 years ago

Attachment: regroup.diff added

comment:1 by Adrian Holovaty, 18 years ago

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