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)

inclusion_template.diff (808 bytes ) - added by Jeremy Dunck 15 years ago.
inclusion_template2.diff (7.4 KB ) - added by tcoenen 13 years ago.
Updated patch now includes tests and documentation as well.

Download all attachments as: .zip

Change History (8)

by Jeremy Dunck, 15 years ago

Attachment: inclusion_template.diff added

comment:1 by Russell Keith-Magee, 15 years ago

Triage Stage: UnreviewedAccepted

comment:2 by Julien Phalip, 14 years ago

Easy pickings: set
Severity: Normal
Type: New feature

Just noting that tests for inclusion_tag have recently been added to source:django/trunk/tests/regressiontests/templates/custom.py

comment:3 by Julien Phalip, 14 years ago

Has patch: set

by tcoenen, 13 years ago

Attachment: inclusion_template2.diff added

Updated patch now includes tests and documentation as well.

comment:4 by tcoenen, 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 Daniel Quinn, 13 years ago

Cc: Daniel Quinn added
Triage Stage: AcceptedReady 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.

comment:6 by Jannis Leidel, 13 years ago

Resolution: fixed
Status: newclosed

In [16374]:

Fixed #11989 -- Allow passing a Template instance to inclusion_tag. Thanks to Jeremy Dunck and tcoenen.

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