Skip to content
Myr

Added changelog entry for #92 and changed LoopContext.End to _last_iteration

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent ea89feb · Browse files · 2 files+8 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+8 added−5 removed

  • other:+8 added−5 removed

2 files+8 added−5 removed

modified:jinja2/runtime.py+6 added-5 removed
28 unmodified lines
2930#: the identity function. Useful for certain things in the environment31identity = lambda x: x3233_last_iteration = object()343536def markup_join(seq):37 """Concatenation that escapes if necessary and converts to unicode."""38 buf = []39 iterator = imap(soft_unicode, seq)
227 unmodified lines
267268269class LoopContext(object):270 """A loop context for dynamic iteration."""269 End = object()271272 def __init__(self, iterable, recurse=None):273 self._iterator = iter(iterable)274 self._recurse = recurse
15 unmodified lines
290 raise TypeError('no items for cycling given')291 return args[self.index0 % len(args)]292293 first = property(lambda x: x.index0 == 0)293 last = property(lambda x: x._after is LoopContext.End)294 last = property(lambda x: x._after is _last_iteration)295 index = property(lambda x: x.index0 + 1)296 revindex = property(lambda x: x.length - x.index0)297 revindex0 = property(lambda x: x.length - x.index)298
6 unmodified lines
305 def _safe_next(self):306 try:307 return next(self._iterator)308 except StopIteration:308 return self.End309 return _last_iteration310311 @internalcode312 def loop(self, iterable):313 if self._recurse is None:
38 unmodified lines
352353 def next(self):354 ctx = self.context355 ctx.index0 += 1355 if ctx._after is LoopContext.End:356 raise StopIteration356 if ctx._after is _last_iteration:357 raise StopIteration()358 next_elem = ctx._after359 ctx._after = ctx._safe_next()360 return next_elem, ctx361
200 unmodified lines
modified:CHANGES+2 added
11 unmodified lines
12- Added a non-silent option for babel extraction.13- Added `urlencode` filter that automatically quotes values for14 URL safe usage with utf-8 as only supported encoding. If applications15 want to change this encoding they can override the filter.16- Accessing `last` on the loop context no longer causes the iterator17 to be consumed into a list.1819Version 2.620-----------21(codename Convolution, released on July 24th 2011)
263 unmodified lines