Opened 17 years ago

Closed 14 years ago

#4552 closed (fixed)

Tidy up "for" tag

Reported by: Chris Beaven Owned by: nobody
Component: Template system Version: dev
Severity: Keywords: for loop
Cc: 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

Just a follow-up patch related to #3523 (Extend "for" tag to allow unpacking of lists) and it's recent checkin.

Currently there is a small difference between the single behaviour and the unpacking behaviour: for unpacking, the context scope is popped every loop iteration. This patch changes this behaviour to use the same scope throughout the loop's lifespan (making it behave more like the older single behaviour).

The patch also tidies up the comma-splitting through the use of re.split.

Attachments (2)

for_tag_tidy.patch (2.3 KB ) - added by Chris Beaven 17 years ago.
for_tag_re_split.patch (674 bytes ) - added by anonymous 14 years ago.

Download all attachments as: .zip

Change History (9)

by Chris Beaven, 17 years ago

Attachment: for_tag_tidy.patch added

comment:1 by Chris Beaven, 17 years ago

Triage Stage: UnreviewedDesign decision needed

comment:2 by Jacob, 17 years ago

Hrm... this is a tricky one. The re.split change is obviously good, but the other one looks like it'll be a bit slower, which I don't like.

comment:3 by Chris Beaven, 15 years ago

Needs tests: set

Going back through some of my old tickets.

If anything, I'd say this would be a speed increase. Currently, we're pushing and popping the context like crazy for unpacked fors. The second for is a safety method which is mostly a noop (except for a len() call) for most normal usage.

Apart from that, it is also a subtle change in behaviour (new items placed on the context are local to each iteration unpacked fors).

comment:4 by Chris Beaven, 14 years ago

Needs tests: unset
Patch needs improvement: set
Triage Stage: Design decision neededAccepted

This is much less important now we have a RenderContext which should be used if you really care about context. Due to the age of the ticket, switching back to the original behavior would potentially cause more side-effects in third party projects than leaving it as-is.

The ticket is being left open because as jacob says the split change is good. So the "improved" patch just needs to do that.

by anonymous, 14 years ago

Attachment: for_tag_re_split.patch added

comment:5 by anonymous, 14 years ago

Triage Stage: AcceptedReady for checkin

comment:6 by anonymous, 14 years ago

Patch needs improvement: unset

comment:7 by Chris Beaven, 14 years ago

Resolution: fixed
Status: newclosed

(In [14656]) Fixed #4552 -- minor tidy up of the {% for %} tag's comma splitting

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