[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
Provenance
- Commit
dbc945d- Tree
adb30ee- Author
Armin Ronacher <armin.ronacher@active-4.com>- Committer
Armin Ronacher <armin.ronacher@active-4.com>- Parent
783d03f
3 files changed+21 added−6 removed
modified:jinja/filters.py+3 added-3 removed
188 unmodified lines189 return 0190 return wrapped191 192 193-def do_reversed():193+def do_reverse():194 """195 Return a reversed list of the sequence filtered. You can use this196 for example for reverse iteration:197 198 .. sourcecode:: jinja199 200- {% 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 lines306 '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 linesmodified:jinja/parser.py+1 added-3 removed
340 unmodified lines341 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('%', '%%'))346 347 except StopIteration:348 raise TemplateSyntaxError('unexpected end of translation section',349 self.tokenstream.last[0])126 unmodified linesmodified:jinja/utils.py+17 added
7 unmodified lines8 :copyright: 2007 by Armin Ronacher.9 :license: BSD, see LICENSE for more details.10 """11 import re12+from jinja.nodes import Trans13 from jinja.datastructure import safe_types, Markup14 15 16 _escape_pairs = {7 unmodified lines24 re.compile('(&|<|>|")'),25 re.compile('(&|<|>)')26 )27 28+29 def 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)))37+38+39+40+def 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())