Opened 12 years ago

Closed 11 years ago

#17356 closed New feature (fixed)

Allow {% include %} to render compiled templates on the context

Reported by: Chris Beaven Owned by: nobody
Component: Template system Version: dev
Severity: Normal Keywords:
Cc: FunkyBob Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

A fanciful example:

template = template.Template('Buy me {% include subtemplate %}.')
context = template.Context({
    'subtemplate': template.Template('some {{ produce }}'),
    'produce': 'apples',
})
print template.render(context)

Attachments (1)

17356.diff (2.5 KB ) - added by Chris Beaven 12 years ago.
Patch with test & docs

Download all attachments as: .zip

Change History (8)

by Chris Beaven, 12 years ago

Attachment: 17356.diff added

Patch with test & docs

comment:1 by Chris Beaven, 12 years ago

Triage Stage: UnreviewedDesign decision needed

comment:2 by Adrian Holovaty, 12 years ago

When would somebody actually need to use this feature?

comment:3 by Chris Beaven, 12 years ago

Well, personally I had the case a while back when I wanted to use a dynamically built sub-template like this.

More recently, someone asked about this in IRC. I had a quick look and saw it was easy to implement.

comment:4 by Jacob, 11 years ago

Triage Stage: Design decision neededAccepted

comment:5 by FunkyBob, 11 years ago

Cc: FunkyBob added

I've just made a PR with a solution to this:

https://github.com/django/django/pull/1525

comment:6 by loic84, 11 years ago

Triage Stage: AcceptedReady for checkin
Version: 1.3master

comment:7 by Anssi Kääriäinen <akaariai@…>, 11 years ago

Resolution: fixed
Status: newclosed

In 5cdacbda034af928f5033c9afc7b50ee0b13f75c:

Fixed #17356 -- Allowed {% include %} to render compiled templates

Reviewed by Loic Bistuer and Tim Graham.

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