Opened 16 years ago
Last modified 10 years ago
#9093 new New feature
Extend inclusion tag syntax to allow custom templates
Reported by: | 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)
Change History (16)
by , 16 years ago
Attachment: | inclusion_tag_using_template.diff added |
---|
comment:1 by , 16 years ago
Has patch: | set |
---|
by , 16 years ago
Attachment: | inclusion_tag_using_template3.diff added |
---|
Fixed diff whitespace, docs typos
by , 16 years ago
Attachment: | inclusion_tag_using_template4.diff added |
---|
allow_template_override is now allow_override
comment:2 by , 16 years ago
Cc: | added |
---|
comment:3 by , 16 years ago
Cc: | added |
---|
comment:5 by , 16 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
comment:6 by , 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 include
s the inclusion_template
that it gets from the context.
comment:7 by , 15 years ago
Cc: | added |
---|
comment:8 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → New feature |
comment:11 by , 12 years ago
Triage Stage: | Design decision needed → Accepted |
---|
comment:12 by , 10 years ago
Patch needs improvement: | set |
---|
Initial version with with docs