You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't like this kind of magic. Some of the loop attributes Jinja provides could use enumerate or itertools.cycle instead, only the ones taking into account the end index of the loop aren't easily done
But how useful are those in practice anyway? Useful enough to warrant the magic? In some simpler cases you can even replace a check for the end of the loop with a check for the beginning of the loop, e.g.
% for foo in bar:
${foo.name}
% if not last:
,
% endif
# ->
% for i, foo in enumerate(bar):
% if i != 0:
,
% end if
${foo.name}
It's safe to ignore the first loop_instrumentation patch. The second one has all the same changes plus a from __future__ import with_statement for people still using python2.5.
Activity
sqlalchemy-bot commentedon Jan 20, 2010
Changes by Michael Bayer (@zzzeek):
sqlalchemy-bot commentedon Jan 21, 2010
Philip Jenvey (@pjenvey) wrote:
I don't like this kind of magic. Some of the loop attributes Jinja provides could use enumerate or itertools.cycle instead, only the ones taking into account the end index of the loop aren't easily done
http://jinja.pocoo.org/2/documentation/templates#for
But how useful are those in practice anyway? Useful enough to warrant the magic? In some simpler cases you can even replace a check for the end of the loop with a check for the beginning of the loop, e.g.
sqlalchemy-bot commentedon Jan 22, 2010
Anonymous wrote:
It's very useful to have access to first, last and cycle item. Productivity boost:)
This is the second feature lacking in Mako (just after not having escape char for %) for my uses cases.
sqlalchemy-bot commentedon Jan 22, 2010
Anonymous wrote:
Also keep in mind for nested loops.
Something like this would come in handy:
sqlalchemy-bot commentedon Mar 5, 2010
Michael Bayer (@zzzeek) wrote:
pushing this off since I'd like to fast track 0.3 a bit
sqlalchemy-bot commentedon Mar 5, 2010
Changes by Michael Bayer (@zzzeek):
sqlalchemy-bot commentedon Nov 13, 2010
Michael Bayer (@zzzeek) wrote:
this is a nice to have but i think 0.4 needs to come out faster than this
sqlalchemy-bot commentedon Nov 13, 2010
Changes by Michael Bayer (@zzzeek):
sqlalchemy-bot commentedon Mar 18, 2012
Anonymous wrote:
It's safe to ignore the first loop_instrumentation patch. The second one has all the same changes plus a
from __future__ import with_statementfor people still using python2.5.sqlalchemy-bot commentedon Mar 24, 2012
Michael Bayer (@zzzeek) wrote:
let's move over to https://bitbucket.org/zzzeek/mako-loop for dev on this
sqlalchemy-bot commentedon Mar 29, 2012
Michael Bayer (@zzzeek) wrote:
merged it in 6e7ad2d - spectacular !!
sqlalchemy-bot commentedon Mar 29, 2012
Changes by Michael Bayer (@zzzeek):