Code

Opened 3 years ago

Closed 11 months ago

#17356 closed New feature (fixed)

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

Reported by: SmileyChris Owned by: nobody
Component: Template system Version: master
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 SmileyChris 3 years ago.
Patch with test & docs

Download all attachments as: .zip

Change History (8)

Changed 3 years ago by SmileyChris

Patch with test & docs

comment:1 Changed 3 years ago by SmileyChris

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Design decision needed

comment:2 Changed 3 years ago by adrian

When would somebody actually need to use this feature?

comment:3 Changed 3 years ago by SmileyChris

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 Changed 15 months ago by jacob

  • Triage Stage changed from Design decision needed to Accepted

comment:5 Changed 11 months ago by FunkyBob

  • Cc FunkyBob added

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

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

comment:6 Changed 11 months ago by loic84

  • Triage Stage changed from Accepted to Ready for checkin
  • Version changed from 1.3 to master

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

  • Resolution set to fixed
  • Status changed from new to closed

In 5cdacbda034af928f5033c9afc7b50ee0b13f75c:

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

Reviewed by Loic Bistuer and Tim Graham.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.