[svn] reversed -> reverse
--HG--
branch : trunk
diff --git a/jinja/filters.py b/jinja/filters.py
index d548d5a..6a0bf33 100644
--- a/jinja/filters.py
+++ b/jinja/filters.py
@@ -190,14 +190,14 @@
return wrapped
-def do_reversed():
+def do_reverse():
"""
Return a reversed list of the sequence filtered. You can use this
for example for reverse iteration:
.. sourcecode:: jinja
- {% for item in seq|reversed %}
+ {% for item in seq|reverse %}
{{ item|e }}
{% endfor %}
"""
@@ -307,7 +307,7 @@
'default': do_default,
'join': do_join,
'count': do_count,
- 'reversed': do_reversed,
+ 'reverse': do_reverse,
'center': do_center,
'title': do_title,
'capitalize': do_capitalize,
diff --git a/jinja/parser.py b/jinja/parser.py
index a95dda8..1bcd0b2 100644
--- a/jinja/parser.py
+++ b/jinja/parser.py
@@ -342,9 +342,7 @@
break
# normal data
else:
- if replacements:
- data = data.replace('%', '%%')
- buf.append(data)
+ buf.append(data.replace('%', '%%'))
except StopIteration:
raise TemplateSyntaxError('unexpected end of translation section',
diff --git a/jinja/utils.py b/jinja/utils.py
index 44b8dc9..7cbf77e 100644
--- a/jinja/utils.py
+++ b/jinja/utils.py
@@ -9,6 +9,7 @@
:license: BSD, see LICENSE for more details.
"""
import re
+from jinja.nodes import Trans
from jinja.datastructure import safe_types, Markup
@@ -24,6 +25,7 @@
re.compile('(&|<|>)')
)
+
def escape(x, attribute=False):
"""
Escape an object x which is converted to unicode first.
@@ -32,3 +34,18 @@
return x
return Markup(_escape_res[not attribute].sub(lambda m:
_escape_pairs[m.group()], unicode(x)))
+
+
+
+def find_translations(environment, source):
+ """
+ Find all translatable strings in a template and yield
+ them as (lineno, singular, plural) tuples. If a plural
+ section does not exist it will be None.
+ """
+ queue = [environment.parse(source)]
+ while queue:
+ node = queue.pop()
+ if node.__class__ is Trans:
+ yield node.lineno, node.singular, node.plural
+ queue.extend(node.getChildNodes())