Code

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#9785 closed (wontfix)

Turn the unordered_list template filter into a block tag.

Reported by: equanimity Owned by: nobody
Component: Template system Version: master
Severity: Keywords: unordered_list block
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

There's a problem with this tag as a filter in that one has no control over how each element in the nested list is rendered, except by changing it's __unicode__ method, which isn't overly practical. For example, say we were trying to output a list of e-mail threads:

{% unordered_list email_list as email %}
<div class="email">
    {{ email.subject }}, {{ email.sent_date }}<br/>
    {{ email.sender }}, {{ email.size }}
</div>
{% endunordered_list %}

In effect, the content of the block replaces the call to __unicode__.

I imagine the name might need to be changed to avoid confusion.
Once there's consensus on whether it'd a good idea and the semantics I'm happy to be the one to write the patch. (My current workaround works so I haven't tried to do things properly yet, particularly as things may change.)

Attachments (0)

Change History (2)

comment:1 Changed 5 years ago by mtredinnick

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to wontfix
  • Status changed from new to closed

The unordered list filter will stay as it is (for backwards compatibility reasons, at a minimum). It's only intended for simple cases and if you have more complex requirements, then writing a custom tag is absolutely the right thing to do. There are many different possibilities for how to turn a list of data into some kind of HTML list and one tag or filter cannot possibly cover all of them.

Closing as wontfix, since the proposal doesn't seem well formed at the moment. Initial design shouldn't be done in a ticket, since it won't involve the right audience. If you want to start a thread on django-developers, please do so. But I suspect you're trying to write a wrapper that will meet infinitely varied requirements, when custom template tags for specific situations are already easy enough to write.

comment:2 Changed 5 years ago by anonymous

  • milestone post-1.0 deleted

Milestone post-1.0 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.