Opened 7 years ago

Closed 6 years ago

#29433 closed New feature (wontfix)

templatefilter "make_list" should receive a optional split variable

Reported by: Maxim Danilov 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 by Tim Graham, 7 years ago

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.

in reply to:  1 comment:2 by Jeff, 7 years ago

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.

in reply to:  1 comment:3 by Jeff, 7 years ago

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 7 years ago by Tim Graham (previous) (diff)

comment:4 by Kamil, 7 years ago

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

comment:5 by Ingo Klöcker, 7 years ago

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 by Tim Graham, 7 years ago

Triage Stage: UnreviewedSomeday/Maybe

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

comment:7 by Kamil, 7 years ago

You can see the discussion here.

comment:8 by Prakash, 7 years ago

Owner: changed from nobody to Prakash
Status: newassigned

Assigning to myself

comment:9 by Tim Graham, 6 years ago

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