Opened 15 years ago
Closed 13 years ago
#11989 closed New feature (fixed)
Allow @register.inclusion_tag to take a template as well as a template name
Reported by: | Jeremy Dunck | Owned by: | nobody |
---|---|---|---|
Component: | Template system | Version: | 1.1 |
Severity: | Normal | Keywords: | |
Cc: | Daniel Quinn | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
Sometimes, I want the convenience of an inclusion_tag without specifying an external template. I can't use simple_tag because I need context access.
@inclusion_tag allows either a template name or an iterable of template names.
The attach patch allows a template to be given directly, as well.
I noticed @inclusion_tag doesn't seem to be currently tested, and this patch doesn't include tests. Where should @inclusion_tag tests live?
Attachments (2)
Change History (8)
by , 15 years ago
Attachment: | inclusion_template.diff added |
---|
comment:1 by , 15 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 14 years ago
Easy pickings: | set |
---|---|
Severity: | → Normal |
Type: | → New feature |
comment:3 by , 14 years ago
Has patch: | set |
---|
by , 13 years ago
Attachment: | inclusion_template2.diff added |
---|
Updated patch now includes tests and documentation as well.
comment:4 by , 13 years ago
Needs documentation: | unset |
---|---|
Needs tests: | unset |
Patch needs improvement: | unset |
UI/UX: | unset |
I updated the patch to apply to the current Django. The patch inclusion_template2.diff now includes documentation and tests for this new feature
comment:5 by , 13 years ago
Cc: | added |
---|---|
Triage Stage: | Accepted → Ready for checkin |
I applied his patch and it passed the tests and then checked out the result in the documentation. All looks good to me.
Just noting that tests for inclusion_tag have recently been added to source:django/trunk/tests/regressiontests/templates/custom.py