Django

Code

Changeset 6913

Show
Ignore:
Timestamp:
12/11/07 00:55:25 (1 year ago)
Author:
gwilson
Message:

Fixed #6151 -- Added some code formatting to the floatformat template filter doc section. Thanks, adamv.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/docs/templates.txt

    r6892 r6913  
    13361336place -- but only if there's a decimal part to be displayed. For example: 
    13371337 
    1338 ========  =======================  ====== 
    1339 value     Template                 Output 
    1340 ========  =======================  ====== 
    1341 34.23234  {{ value|floatformat }}  34.2 
    1342 34.00000  {{ value|floatformat }}  34 
    1343 34.26000  {{ value|floatformat }}  34.3 
    1344 ========  =======================  ====== 
     1338============  ===========================  ======== 
     1339``value``     Template                     Output 
     1340============  ===========================  ======== 
     1341``34.23234``  ``{{ value|floatformat }}``  ``34.2`` 
     1342``34.00000``  ``{{ value|floatformat }}``  ``34`` 
     1343``34.26000``  ``{{ value|floatformat }}``  ``34.3`` 
     1344============  ===========================  ======== 
    13451345 
    13461346If used with a numeric integer argument, ``floatformat`` rounds a number to 
    13471347that many decimal places. For example: 
    13481348 
    1349 ========  =========================  ====== 
    1350 value     Template                   Output 
    1351 ========  =========================  ====== 
    1352 34.23234  {{ value|floatformat:3 }}  34.232 
    1353 34.00000  {{ value|floatformat:3 }}  34.000 
    1354 34.26000  {{ value|floatformat:3 }}  34.260 
    1355 ========  =========================  ====== 
     1349============  =============================  ========== 
     1350``value``     Template                       Output 
     1351============  =============================  ========== 
     1352``34.23234``  ``{{ value|floatformat:3 }}``  ``34.232`` 
     1353``34.00000``  ``{{ value|floatformat:3 }}``  ``34.000`` 
     1354``34.26000``  ``{{ value|floatformat:3 }}``  ``34.260`` 
     1355============  =============================  ========== 
    13561356 
    13571357If the argument passed to ``floatformat`` is negative, it will round a number 
     
    13591359displayed. For example: 
    13601360 
    1361 ========  ============================  ====== 
    1362 value     Template                      Output 
    1363 ========  ============================  ====== 
    1364 34.23234  {{ value|floatformat:"-3" }}  34.232 
    1365 34.00000  {{ value|floatformat:"-3" }}  34 
    1366 34.26000  {{ value|floatformat:"-3" }}  34.260 
    1367 ========  ============================  ====== 
     1361============  ================================  ========== 
     1362``value``     Template                          Output 
     1363============  ================================  ========== 
     1364``34.23234``  ``{{ value|floatformat:"-3" }}``  ``34.232`` 
     1365``34.00000``  ``{{ value|floatformat:"-3" }}``  ``34`` 
     1366``34.26000``  ``{{ value|floatformat:"-3" }}``  ``34.260`` 
     1367============  ================================  ========== 
    13681368 
    13691369Using ``floatformat`` with no argument is equivalent to using ``floatformat``