Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added pretty tables for `floatformat` documentation.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@6648 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 6f7fd897bcc20ef5a3b96a3caf01d805d631d3e4 1 parent a5eb61c
Gary Wilson Jr. gdub authored
Showing with 33 additions and 19 deletions.
  1. +33 −19 docs/templates.txt
52 docs/templates.txt
View
@@ -1106,25 +1106,39 @@ floatformat
When used without an argument, rounds a floating-point number to one decimal
place -- but only if there's a decimal part to be displayed. For example:
- * ``36.123`` gets converted to ``36.1``
- * ``36.15`` gets converted to ``36.2``
- * ``36`` gets converted to ``36``
-
-If used with a numeric integer argument, ``floatformat`` rounds a number to that
-many decimal places. For example:
-
- * ``36.1234`` with floatformat:3 gets converted to ``36.123``
- * ``36`` with floatformat:4 gets converted to ``36.0000``
-
-If the argument passed to ``floatformat`` is negative, it will round a number to
-that many decimal places -- but only if there's a decimal part to be displayed.
-For example:
-
- * ``36.1234`` with floatformat:-3 gets converted to ``36.123``
- * ``36`` with floatformat:-4 gets converted to ``36``
-
-Using ``floatformat`` with no argument is equivalent to using ``floatformat`` with
-an argument of ``-1``.
+======== ======================= ======
+value Template Output
+======== ======================= ======
+34.23234 {{ value|floatformat }} 34.2
+34.00000 {{ value|floatformat }} 34
+34.26000 {{ value|floatformat }} 34.3
+======== ======================= ======
+
+If used with a numeric integer argument, ``floatformat`` rounds a number to
+that many decimal places. For example:
+
+======== ========================= ======
+value Template Output
+======== ========================= ======
+34.23234 {{ value|floatformat:3 }} 34.232
+34.00000 {{ value|floatformat:3 }} 34.000
+34.26000 {{ value|floatformat:3 }} 34.260
+======== ========================= ======
+
+If the argument passed to ``floatformat`` is negative, it will round a number
+to that many decimal places -- but only if there's a decimal part to be
+displayed. For example:
+
+======== ============================ ======
+value Template Output
+======== ============================ ======
+34.23234 {{ value|floatformat:"-3" }} 34.232
+34.00000 {{ value|floatformat:"-3" }} 34
+34.26000 {{ value|floatformat:"-3" }} 34.260
+======== ============================ ======
+
+Using ``floatformat`` with no argument is equivalent to using ``floatformat``
+with an argument of ``-1``.
get_digit
~~~~~~~~~
Please sign in to comment.
Something went wrong with that request. Please try again.