#8088 closed New feature (wontfix)
Template system improvement: "cat" filter, "include" tag with filters
Reported by: | David Avsajanishvili | Owned by: | nobody |
---|---|---|---|
Component: | Template system | Version: | dev |
Severity: | Normal | Keywords: | cat concatenate include filter tag |
Cc: | Triage Stage: | Design decision needed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
There are two suggestions:
- Since we have add filter, that adds a value to integer variable, why not implement cat filter, which will concatenate strings? I think, it would be useful for many developers!
- include tag has two options: template name could be specified either as a quoted string, or as a variable. But for all that template filters cannot be used. It would be nice to allow developers to specify template name more flexibly, for example:
{% include var_name|lower %}
or even like this (page5_ka.txt):
{% include "page"|cat:pageid|cat:LANGUAGE_CODE|cat:"_.txt" %}
The diffs attached to the ticket do these things. At the same time, new revision of template system will be fully backwards-compatible with previous.
An only exception is - using quoted strings with quotes inside, like this:
{% include "a"mysterious"template.txt" %}
Currently, template system accepts this string as a template name with doublequotes inside, while modified - won't. But, IMHO, nobody will name templates this case.
Attachments (3)
Change History (15)
by , 16 years ago
Attachment: | cat_filter.diff added |
---|
by , 16 years ago
Attachment: | include_tag.diff added |
---|
"include" tag modified so, it can process template filters
by , 16 years ago
Attachment: | templates_doc.diff added |
---|
"cat" filter and "include" tag description update in documentation
follow-up: 2 comment:1 by , 16 years ago
{% include "page"|cat:pageid|cat:LANGUAGE_CODE|cat:"_.txt" %}
I think that's to many logic in template.
comment:2 by , 16 years ago
I think that's to many logic in template.
Yes, but such usage is only an option available.
Although in some cases it might be useful.
See google-groups:
http://groups.google.com/group/django-developers/browse_thread/thread/21631ff4141a8db3
follow-up: 4 comment:3 by , 16 years ago
comment:4 by , 16 years ago
Replying to emulbreh:
The
{% include %}
fix is a duplicate of #5862 and #5756, and would be fixed by #7806.
Good! Exactly that I have in mind!
Please, take into account this: http://code.djangoproject.com/attachment/ticket/5756/5756.3.patch
comment:5 by , 16 years ago
milestone: | → post-1.0 |
---|
comment:6 by , 16 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
comment:9 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → New feature |
comment:10 by , 13 years ago
Easy pickings: | unset |
---|---|
Resolution: | → wontfix |
Status: | new → closed |
UI/UX: | unset |
These are both useful features, but both can be implemented externally, and they don't cross the threshold of being widely useful. Thus, they're not a great match to include in Django's core.
Thanks!
comment:11 by , 13 years ago
It's hard to objectively assess what the threshold of being widely useful is. Speaking of the "concat" filter, I personally thought it actually crossed that threshold, based my own experience and that of several co-workers...
"cat" filter (concatenate argument with value)