Opened 5 years ago

Closed 3 years 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


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 5 years ago.
Patch with test & docs

Download all attachments as: .zip

Change History (8)

Changed 5 years ago by SmileyChris

Patch with test & docs

comment:1 Changed 5 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 5 years ago by adrian

When would somebody actually need to use this feature?

comment:3 Changed 5 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 3 years ago by jacob

  • Triage Stage changed from Design decision needed to Accepted

comment:5 Changed 3 years ago by FunkyBob

  • Cc FunkyBob added

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

comment:6 Changed 3 years ago by loic84

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

comment:7 Changed 3 years 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.

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