Instrument iterables ala jinja ? #125
Comments
Changes by Michael Bayer (@zzzeek):
|
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.
|
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. |
Anonymous wrote: Also keep in mind for nested loops. Something like this would come in handy:
|
Michael Bayer (@zzzeek) wrote: pushing this off since I'd like to fast track 0.3 a bit |
Changes by Michael Bayer (@zzzeek):
|
Michael Bayer (@zzzeek) wrote: this is a nice to have but i think 0.4 needs to come out faster than this |
Changes by Michael Bayer (@zzzeek):
|
Anonymous wrote: It's safe to ignore the first loop_instrumentation patch. The second one has all the same changes plus a |
Michael Bayer (@zzzeek) wrote: let's move over to https://bitbucket.org/zzzeek/mako-loop for dev on this |
Changes by Michael Bayer (@zzzeek):
|
Migrated issue, originally created by Michael Bayer (@zzzeek)
i.e. user does this:
we see the magic name "lastelement". We then compile to this:
easy !
tentative 0.3 feature. May come out.
Attachments: loop_instrumentation.patch | loop_instrumentation.2.patch | 125.patch
The text was updated successfully, but these errors were encountered: