Opened 14 years ago
Closed 12 years ago
#13984 closed New feature (duplicate)
template.loader.select_template should return template_name as well.
Reported by: | Daniel Duan | Owned by: | Josh Stegmaier |
---|---|---|---|
Component: | Template system | Version: | dev |
Severity: | Normal | Keywords: | |
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
The whole purpose of this function is to find out which possible location of a certain template is valid. It make sense to return the compiled template as well as its location.
Here's a common use case:
A template is found by select_template, however, this template extends an "base.html" whose is located in the same directory, which is unknown until runtime as well. So the extends tag fails.
If select_template returns the location of the template it finds, then this info could be passed into an context and thus make the extends tag useful again.
Attachments (2)
Change History (9)
by , 14 years ago
Attachment: | 0001-Added-template_name-as-a-return-value-of-django.temp.patch added |
---|
comment:1 by , 14 years ago
Summary: | template.select_template should return template_name as well. → template.loader.select_template should return template_name as well. |
---|
The whole purpose of this function is to find out which possible location of a certain template is valid. It make sense to return the compiled template as well as its location.
Here's a common use case:
A template is found by select_template, however, this template extends an "base.html" whose is located in the same directory, which is unknown until runtime as well. So the extends tag fails.
If select_template returns the location of the template it finds, then this info could be passed into an context and thus make the extends tag useful again.
by , 14 years ago
Attachment: | 0002-template_name-as-optional-return-value-of-django.temp.diff added |
---|
Adds option to return template name with select_template and documents change.
comment:2 by , 14 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
In order to maintain backwards compatibility, it would probably be better if returning the template name was optional. I've attached a patch that would accomplish this.
comment:3 by , 14 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
comment:4 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → New feature |
comment:7 by , 12 years ago
Resolution: | → duplicate |
---|---|
Status: | assigned → closed |
The pattern used to change the result type isn't elegant...
It seems to me that #16096 provides the same information with a better API.
Added template_name as an return value to select_template