From: Armin Ronacher Date: Sat, 6 Feb 2010 22:33:11 +0000 (+0100) Subject: Fixed #367 by improving the documentation. X-Git-Tag: 2.3~31 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=1ef7703cdcade0cc270cb4369c2b8adc4afa9210;p=jinja2.git Fixed #367 by improving the documentation. --HG-- branch : trunk --- diff --git a/jinja2/filters.py b/jinja2/filters.py index 4b85c30..3da4221 100644 --- a/jinja2/filters.py +++ b/jinja2/filters.py @@ -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')