Django

Code

Changeset 6646

Show
Ignore:
Timestamp:
11/03/07 21:27:17 (1 year ago)
Author:
gwilson
Message:

floatformat template filter docstring changes:

  • Split example cases.
  • Corrected use with negative arguments (quotes are needed).
  • Added another example of a number that has decimal places that include a non-zero digit and that ends with zeros.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/template/defaultfilters.py

    r6643 r6646  
    5555def floatformat(text, arg=-1): 
    5656    """ 
    57     If called without an argument, displays a floating point 
    58     number as 34.2 -- but only if there's a point to be displayed. 
    59     With a positive numeric argument, it displays that many decimal places 
    60     always. 
    61     With a negative numeric argument, it will display that many decimal 
    62     places -- but only if there's places to be displayed. 
    63     Examples: 
     57    Displays a float to a specified number of decimal places. 
     58 
     59    If called without an argument, it displays the floating point number with 
     60    one decimal place -- but only if there's a decimal place to be displayed: 
    6461 
    6562    * num1 = 34.23234 
    6663    * num2 = 34.00000 
    67     * num1|floatformat results in 34.2 
    68     * num2|floatformat is 34 
    69     * num1|floatformat:3 is 34.232 
    70     * num2|floatformat:3 is 34.000 
    71     * num1|floatformat:-3 is 34.232 
    72     * num2|floatformat:-3 is 34 
     64    * num3 = 34.26000 
     65    * {{ num1|floatformat }} displays "34.2" 
     66    * {{ num2|floatformat }} displays "34" 
     67    * {{ num3|floatformat }} displays "34.3" 
     68 
     69    If arg is positive, it will always display exactly arg number of decimal 
     70    places: 
     71 
     72    * {{ num1|floatformat:3 }} displays "34.232" 
     73    * {{ num2|floatformat:3 }} displays "34.000" 
     74    * {{ num3|floatformat:3 }} displays "34.260" 
     75 
     76    If arg is negative, it will display arg number of decimal places -- but 
     77    only if there are places to be displayed: 
     78 
     79    * {{ num1|floatformat:"-3" }} displays "34.232" 
     80    * {{ num2|floatformat:"-3" }} displays "34" 
     81    * {{ num3|floatformat:"-3" }} displays "34.260" 
    7382    """ 
    7483    try: