Opened 15 years ago
Closed 15 years ago
#11910 closed (wontfix)
More flexible urlize template filter (passing a function that will execute for each url)
Reported by: | Stefan_Petrea | Owned by: | nobody |
---|---|---|---|
Component: | Template system | Version: | 1.1 |
Severity: | Keywords: | template customize | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Hi,
I'd like to have more control over how the links are generated through the urlize built-in filter.
To be more specific , I'd like to be able to pass a lambda or a subroutine(sorry I don't know how you call it in Python)
so that it will be called for each link it detects on that particular text and let me modify it how I want.
Of course, I cannot do that from the template Language , so what I propose is
a urlize Factory that will let the user build his own customized urlize filter.
new_filter = build_urlize_filter(do_when_url_encountered)
and pass to do_when_url_encountered the url each time one is encountered so that
the user can write his own code on what he thinks is right to be done here
(My particular needs would be to get the text from the last '/' to the end of the link and use that as the text
for the link)
Best regards,
Stefan
Change History (3)
comment:1 by , 15 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
comment:2 by , 15 years ago
Resolution: | wontfix |
---|---|
Status: | closed → reopened |
ok, let me give another motivation for this particular addition.
for example , you know that in a Google search each link has a [cache] link near it , well .. that's what I need also,
to cache links that users will enter in some field in order to have a backup for downtime.
comment:3 by , 15 years ago
Resolution: | → wontfix |
---|---|
Status: | reopened → closed |
If you disagree with a decision that has been made on Trac, *please* follow the process and start a discussion on django-developers.
The spec you have provided is fairly vague, and I'm not sure I see the value. urlize performs a very specific (and relatively common) function, and I can't say I've found myself wanting a factory for producing urlize-style filters.
Also, this is something that can easily live external to the Django core - either as a snippet or as part of a larger library of template tags. If time proves that this is a particularly useful feature, we can look at integrating it into the core.