Django

Code

Changeset 6643

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

Added examples to the pluralize template filter's docstring.

Files:

Legend:

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

    r6641 r6643  
    583583def pluralize(value, arg=u's'): 
    584584    """ 
    585     Returns a plural suffix if the value is not 1, for '1 vote' vs. '2 votes' 
    586     By default, 's' is used as a suffix; if an argument is provided, that string 
    587     is used instead. If the provided argument contains a comma, the text before 
    588     the comma is used for the singular case. 
     585    Returns a plural suffix if the value is not 1.  By default, 's' is used as 
     586    the suffix: 
     587 
     588    * If value is 0, vote{{ value|plurlize }} displays "0 votes". 
     589    * If value is 1, vote{{ value|plurlize }} displays "1 vote". 
     590    * If value is 2, vote{{ value|plurlize }} displays "2 votes". 
     591 
     592    If an argument is provided, that string is used instead: 
     593 
     594    * If value is 0, class{{ value|plurlize:"es" }} displays "0 classes". 
     595    * If value is 1, class{{ value|plurlize:"es" }} displays "1 class". 
     596    * If value is 2, class{{ value|plurlize:"es" }} displays "2 classes". 
     597 
     598    If the provided argument contains a comma, the text before the comma is 
     599    used for the singular case and the text after the comma is used for the 
     600    plural case: 
     601 
     602    * If value is 0, cand{{ value|plurlize:"y,ies" }} displays "0 candies". 
     603    * If value is 1, cand{{ value|plurlize:"y,ies" }} displays "1 candy". 
     604    * If value is 2, cand{{ value|plurlize:"y,ies" }} displays "2 candies". 
    589605    """ 
    590606    if not u',' in arg: