Opened 16 years ago

Closed 14 years ago

Last modified 13 years ago

#9456 closed (fixed)

Extend with tag to support multiple bindings

Reported by: eibaan Owned by: Łukasz Rekucki
Component: Template system Version: 1.0
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Attached is a patch that extends the with template tag in a fully backward compatible way (I hope) so that you can write

{% with expr1 as var1 and expr2 as var2 and expr3 as var3 %} ...

instead of

{% with expr1 as var1 %}
    {% with expr2 as var2 %}
        {% with expr3 as var3 %}
            ...

Attachments (2)

with.patch (3.4 KB ) - added by eibaan 16 years ago.
ticket9456_r13997.diff (5.0 KB ) - added by Łukasz Rekucki 14 years ago.
Patch from #7817, but only has "with" related stuff.

Download all attachments as: .zip

Change History (10)

by eibaan, 16 years ago

Attachment: with.patch added

comment:1 by Johannes Dollinger, 16 years ago

duplicate of #7817.

comment:2 by Jacob, 16 years ago

Resolution: duplicate
Status: newclosed

comment:3 by Antti Kaihola, 16 years ago

I attached eibaan's patch above with slight improvements to #7817.

comment:4 by Chris Beaven, 14 years ago

Resolution: duplicate
Status: closedreopened
Triage Stage: UnreviewedDesign decision needed

#7817 dealt with two separate feature requests here, one for {% with %} and one for {% include %}.

I'm leaving that one to deal with just {% include %} and reopening this one to track {% with %}

comment:5 by Łukasz Rekucki, 14 years ago

Owner: changed from nobody to Łukasz Rekucki
Status: reopenednew

Ok, I'm goning to split the with part form #7817. It's diffrent from patch on this ticket, that it resolves all variables in the outer context, so you can do

  {% with x as y and y as x %}{% endwith %}

to swap the variables. It's also with line how Python does assignment and how most languages handle "let" statement (which I find very similar in semantic to the with tag).

by Łukasz Rekucki, 14 years ago

Attachment: ticket9456_r13997.diff added

Patch from #7817, but only has "with" related stuff.

comment:6 by Russell Keith-Magee, 14 years ago

milestone: 1.3
Triage Stage: Design decision neededAccepted

Following a BDFL pronouncement, this has been accepted, using the {% with foo=x bar=y %} syntax. Related ticket: #7817.

comment:7 by Chris Beaven, 14 years ago

Resolution: fixed
Status: newclosed

(In [14922]) Fixes #7817 and #9456.

  • The include tag now has a 'with' option to include to provide extra context vairables to the included template.
  • The include tag now has an 'only' option to exclude the current context when rendering the included template.
  • The with tag now accepts multiple variable assignments.
  • The with, include and blocktrans tags now use a new keyword argument format for variable assignments (e.g. {% with foo=1 bar=2 %}).

comment:19 by Jacob, 13 years ago

milestone: 1.3

Milestone 1.3 deleted

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