Opened 14 years ago

Closed 11 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)

0001-Added-template_name-as-a-return-value-of-django.temp.patch (1.7 KB ) - added by Daniel Duan 14 years ago.
Added template_name as an return value to select_template
0002-template_name-as-optional-return-value-of-django.temp.diff (1.8 KB ) - added by Josh Stegmaier 14 years ago.
Adds option to return template name with select_template and documents change.

Download all attachments as: .zip

Change History (9)

by Daniel Duan, 14 years ago

Added template_name as an return value to select_template

comment:1 by Daniel Duan, 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 Josh Stegmaier, 14 years ago

Adds option to return template name with select_template and documents change.

comment:2 by Josh Stegmaier, 14 years ago

Owner: changed from nobody to Josh Stegmaier
Status: newassigned

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 Josh Stegmaier, 14 years ago

Triage Stage: UnreviewedDesign decision needed

comment:4 by Graham King, 13 years ago

Severity: Normal
Type: New feature

comment:5 by Aymeric Augustin, 12 years ago

UI/UX: unset

Change UI/UX from NULL to False.

comment:6 by Aymeric Augustin, 12 years ago

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:7 by Aymeric Augustin, 11 years ago

Resolution: duplicate
Status: assignedclosed

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.

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