Opened 16 years ago

Last modified 10 years ago

#9093 new New feature

Extend inclusion tag syntax to allow custom templates

Reported by: exogen@… Owned by: nobody
Component: Template system Version: 1.0
Severity: Normal Keywords: inclusion
Cc: edcrypt@…, andy@…, ramusus@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

Currently, inclusion tags are not very reusable since they are bound to a template at registration time. For example, the only way to customize Djagno admin's change_list_results.html template is to ensure your template of the same name is found first. I propose extending the inclusion tag syntax so that all inclusion tags can be called like so:

{% show_results poll using "custom/results.html" %}

If the "using ..." part is omitted, the template specified during registration will be used. (The keyword decided upon, 'using' in this case, is not important.)

The only problem: this could break existing apps that use the keyword ('using' in this case) as a variable name. But we can make this behavior well-defined.

Attachments (4)

inclusion_tag_using_template.diff (5.1 KB ) - added by exogen@… 16 years ago.
Initial version with with docs
inclusion_tag_using_template2.diff (4.6 KB ) - added by exogen@… 16 years ago.
Fixed typos in docs
inclusion_tag_using_template3.diff (4.7 KB ) - added by exogen@… 16 years ago.
Fixed diff whitespace, docs typos
inclusion_tag_using_template4.diff (5.0 KB ) - added by exogen@… 16 years ago.
allow_template_override is now allow_override

Download all attachments as: .zip

Change History (16)

by exogen@…, 16 years ago

Initial version with with docs

by exogen@…, 16 years ago

Fixed typos in docs

comment:1 by anonymous, 16 years ago

Has patch: set

by exogen@…, 16 years ago

Fixed diff whitespace, docs typos

by exogen@…, 16 years ago

allow_template_override is now allow_override

comment:2 by anonymous, 16 years ago

Cc: edcrypt@… added

comment:3 by Andy Baker, 16 years ago

Cc: andy@… added

comment:4 by (none), 16 years ago

milestone: post-1.0

Milestone post-1.0 deleted

comment:5 by Jacob, 16 years ago

Triage Stage: UnreviewedDesign decision needed

comment:6 by Andrew Badr, 16 years ago

Even if you're willing to write multiple inclusion tags for some finite number of templates that take the same context, you have to write a wrapper around the context function. (Django won't let you use the same function for multiple inclusion tags.) One possible workaround might be to do {% with inclusion_template as 'whatever'%}{% show_result %}{% endwith %} and show_result would render a template that includes the inclusion_template that it gets from the context.

comment:7 by ramusus, 15 years ago

Cc: ramusus@… added

comment:8 by Luke Plant, 14 years ago

Severity: Normal
Type: New feature

comment:9 by Aymeric Augustin, 13 years ago

UI/UX: unset

Change UI/UX from NULL to False.

comment:10 by Aymeric Augustin, 13 years ago

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:11 by Jacob, 12 years ago

Triage Stage: Design decision neededAccepted

comment:12 by Tim Graham, 10 years ago

Patch needs improvement: set
Note: See TracTickets for help on using tickets.
Back to Top