fragile nodes must be exception or memory pinned
[libfirm] / scripts / jinja2 / filters.py
index afa7667..3da4221 100644 (file)
@@ -5,7 +5,7 @@
 
     Bundled jinja filters.
 
-    :copyright: 2008 by Armin Ronacher, Christoph Hack.
+    :copyright: (c) 2010 by the Jinja Team.
     :license: BSD, see LICENSE for more details.
 """
 import re
@@ -18,7 +18,7 @@ from jinja2.runtime import Undefined
 from jinja2.exceptions import FilterArgumentError, SecurityError
 
 
-_word_re = re.compile(r'\w+')
+_word_re = re.compile(r'\w+(?u)')
 
 
 def contextfilter(f):
@@ -285,8 +285,8 @@ def do_random(environment, seq):
 def do_filesizeformat(value, binary=False):
     """Format the value like a 'human-readable' file size (i.e. 13 KB,
     4.1 MB, 102 bytes, etc).  Per default decimal prefixes are used (mega,
-    giga etc.), if the second parameter is set to `True` the binary
-    prefixes are (mebi, gibi).
+    giga, etc.), if the second parameter is set to `True` the binary
+    prefixes are used (mebi, gibi).
     """
     bytes = float(value)
     base = binary and 1024 or 1000
@@ -452,7 +452,7 @@ def do_striptags(value):
 def do_slice(value, slices, fill_with=None):
     """Slice an iterator and return a list of lists containing
     those items. Useful if you want to create a div containing
-    three div tags that represent columns:
+    three ul tags that represent columns:
 
     .. sourcecode:: html+jinja
 
@@ -498,7 +498,7 @@ def do_batch(value, linecount, fill_with=None):
         {%- for row in items|batch(3, ' ') %}
           <tr>
           {%- for column in row %}
-            <tr>{{ column }}</td>
+            <td>{{ column }}</td>
           {%- endfor %}
           </tr>
         {%- endfor %}
@@ -531,9 +531,17 @@ def do_round(value, precision=0, method='common'):
     .. sourcecode:: jinja
 
         {{ 42.55|round }}
-            -> 43
+            -> 43.0
         {{ 42.55|round(1, 'floor') }}
             -> 42.5
+
+    Note that even if rounded to 0 precision, a float is returned.  If
+    you need a real integer, pipe it through `int`:
+
+    .. sourcecode:: jinja
+
+        {{ 42.55|round|int }}
+            -> 43
     """
     if not method in ('common', 'ceil', 'floor'):
         raise FilterArgumentError('method must be common, ceil or floor')