Code

Opened 8 years ago

Closed 8 years ago

Last modified 6 years ago

#2102 closed enhancement (fixed)

[patch] Enable the template for loop to work with a generator.

Reported by: dbm-django@… Owned by: adrian
Component: Template system Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

The template system's for loop currently doesn't work with a generator because the length of the iterable is required for the variables forloop.revcounter, forloop.revcounter0 and forloop.last.

This patch simply checks for a len attribute on the iterable. If it doesn't exist, a list is created from the iterable and used in its place.

Attachments (1)

for_loop_with_generator.diff (465 bytes) - added by dbm-django@… 8 years ago.

Download all attachments as: .zip

Change History (3)

Changed 8 years ago by dbm-django@…

comment:1 Changed 8 years ago by adrian

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

(In [3165]) Fixed #2102 -- Template system 'for' loops now support generators. Thanks, dbm-django@…

comment:3 Changed 6 years ago by kmtracey

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.