Opened 10 years ago

Closed 4 years ago

#22162 closed New feature (wontfix)

new filter tags for string processing on templates

Reported by: alvaro@… Owned by: nobody
Component: Template system Version: 1.6
Severity: Normal Keywords: filter tags
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I created a new feature with more than 10 new function for String filter tags. I have a path that complements defaultfilter.py.

This path contains the following functions:

1-reverseString
2-trim
3-parseInt
4-endsWith
5-startsWith
6-toLowerCase
7-toUpperCase
8-arrayMin
9-arrayMax
10-exp
11-pow
12-factorial
13-toHiperLink
14-DictShowKeys
15-DictToString

Attachments (1)

extra_filters.py (4.8 KB ) - added by alvaro@… 10 years ago.
this .py contains new features for filter tags.

Download all attachments as: .zip

Change History (4)

by alvaro@…, 10 years ago

Attachment: extra_filters.py added

this .py contains new features for filter tags.

comment:1 by loic84, 10 years ago

Resolution: wontfix
Status: newclosed

Hi alvaro@, thanks for your suggestion and taking the time to offer a patch, but it's very unlikely this ticket can be accepted. The set of filters that Django ships by default is deliberately minimal, and anything more specific is better handled in 3rd party libs.

Sadly this kind of simple wrappers only exist because Django templates' dot notation doesn't handle passing arguments to functions/methods. There are active discussions on the mailing about switching to Jinja2 which would address this issue.

Please note that you can probably do away with some of the filters in that list, namely trim, toLowerCase and toUpperCase since their equivalent string methods don't require arguments and can be called directly (e.g. {{ item.uper.strip }}).

comment:2 by KESHAV KUMAR, 4 years ago

Resolution: wontfix
Status: closednew

there are many inbuilt filters ( e.g. 'join' ) which work on advance logic and as argument taking functions. I think it would be helpful to make two more filters ( startsWith and endWith ) such that it can make templates more intellectual.

comment:3 by Mariusz Felisiak, 4 years ago

Resolution: wontfix
Status: newclosed

This ticket is about adding more than ten new filters, you probably based reopening on discussion. Nevertheless I don't see a strong consensus in this discussion and IMO we don't want to add more template filters because it's really straightforward to add a custom one.

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