Skip to content
Myr

[svn] reversed -> reverse

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

--HG-- branch : trunk

authored by Armin Ronacher · committed by Armin Ronacher · parent 783d03f · Browse files · 3 files+21 added−6 removed
This commit

State

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

Diff stats

3 files+21 added−6 removed

  • other:+21 added−6 removed

3 files+21 added−6 removed

modified:jinja/filters.py+3 added-3 removed
188 unmodified lines
189 return 0190 return wrapped191192193def do_reversed():193def do_reverse():194 """195 Return a reversed list of the sequence filtered. You can use this196 for example for reverse iteration:197198 .. sourcecode:: jinja199200 {% for item in seq|reversed %}200 {% for item in seq|reverse %}201 {{ item|e }}202 {% endfor %}203 """204 def wrapped(env, context, value):
101 unmodified lines
306 'title': do_title,307 'default': do_default,308 'join': do_join,309 'count': do_count,310 'reversed': do_reversed,310 'reverse': do_reverse,311 'center': do_center,312 'title': do_title,313 'capitalize': do_capitalize,314 'first': do_first,
5 unmodified lines
modified:jinja/parser.py+1 added-3 removed
340 unmodified lines
341 self.close_remaining_block()342 break343 # normal data344 else:345 if replacements:346 data = data.replace('%', '%%')347 buf.append(data)345 buf.append(data.replace('%', '%%'))346347 except StopIteration:348 raise TemplateSyntaxError('unexpected end of translation section',349 self.tokenstream.last[0])
126 unmodified lines
modified:jinja/utils.py+17 added
7 unmodified lines
8 :copyright: 2007 by Armin Ronacher.9 :license: BSD, see LICENSE for more details.10"""11import re12from jinja.nodes import Trans13from jinja.datastructure import safe_types, Markup141516_escape_pairs = {
7 unmodified lines
24 re.compile('(&|<|>|")'),25 re.compile('(&|<|>)')26)272829def escape(x, attribute=False):30 """31 Escape an object x which is converted to unicode first.32 """33 if type(x) in safe_types:34 return x35 return Markup(_escape_res[not attribute].sub(lambda m:36 _escape_pairs[m.group()], unicode(x)))37383940def find_translations(environment, source):41 """42 Find all translatable strings in a template and yield43 them as (lineno, singular, plural) tuples. If a plural44 section does not exist it will be None.45 """46 queue = [environment.parse(source)]47 while queue:48 node = queue.pop()49 if node.__class__ is Trans:50 yield node.lineno, node.singular, node.plural51 queue.extend(node.getChildNodes())