Opened 3 months ago

Closed 3 weeks ago

#29433 closed New feature (wontfix)

templatefilter "make_list" should receive a optional split variable

Reported by: danilovmy Owned by: Prakash
Component: Template system Version:
Severity: Normal Keywords: templatefilter,
Cc: Jeff Triage Stage: Someday/Maybe
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description (last modified by Tim Graham)

for use in template, for example:
not only

{% with my_list='i#am#stupid#user'|make_list %}
# my_list=['i','#','a','m','#','s','t','u','p','i','d','#','u','s','e','r']

......

it should to work too:

{% with my_list='i#am#stupid#user'|make_list:'#' %}
# my_list=['i','am','stupid','user']

......

Change History (9)

comment:1 Changed 3 months ago by Tim Graham

Description: modified (diff)

I'm on the fence. While I see the value, I'm not sure that promoting more logic in templates in a good idea. It's fairly easy to write a custom filter (I would call it "split") which I think would be more readable.

comment:2 in reply to:  1 Changed 3 months ago by Jeff

I feel somewhat ambivalent about this as well. If we decide to add the split feature, would it make more sense to add a new tag "split" instead of changing the behavior or "make_list" Do we want to add this at all?

Replying to Tim Graham:

I'm on the fence. While I see the value, I'm not sure that promoting more logic in templates in a good idea. It's fairly easy to write a custom filter (I would call it "split") which I think would be more readable.

comment:3 in reply to:  1 Changed 3 months ago by Jeff

Cc: Jeff added

I feel somewhat ambivalent about this as well. If we decide to add the split feature, would it make more sense to add a new tag "split" instead of changing the behavior of "make_list". Do we want to add this at all?

Replying to Tim Graham:

I'm on the fence. While I see the value, I'm not sure that promoting more logic in templates in a good idea. It's fairly easy to write a custom filter (I would call it "split") which I think would be more readable.

Last edited 3 months ago by Tim Graham (previous) (diff)

comment:4 Changed 3 months ago by Kamil

If we decide to do it, I will be happy to do it.

comment:5 Changed 3 months ago by Ingo Klöcker

I also think that adding a split filter (there's already a join filter) is useful. Sometimes we store lists of strings in simple CharFields and for display we need to replace the separator with a more human-friendly separator.

So, who's going to decide if it shall be added?

comment:6 Changed 3 months ago by Tim Graham

Triage Stage: UnreviewedSomeday/Maybe

Write to the DevelopersMailingList to get a consensus about how to proceed.

comment:7 Changed 3 months ago by Kamil

You can see the discussion here.

comment:8 Changed 2 months ago by Prakash

Owner: changed from nobody to Prakash
Status: newassigned

Assigning to myself

comment:9 Changed 3 weeks ago by Tim Graham

Resolution: wontfix
Status: assignedclosed

Closing as the mailing list didn't yield consensus to add this.

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