[patch] Enable the template for loop to work with a generator.
|Reported by:||Owned by:||Adrian Holovaty|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
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.