Ticket #3696: defaulttags.diff

File defaulttags.diff, 3.1 KB (added by Simon G. <dev@…>, 18 years ago)
  • django_src/django/template/defaulttags.py

     
    435435cycle = register.tag(cycle)
    436436
    437437def debug(parser, token):
     438    """
     439    Output a whole load of debugging information, including the current context and imported modules.
     440
     441    Sample usage::
     442
     443        <pre>
     444            {% debug %}
     445        </pre>
     446    """
    438447    return DebugNode()
    439448debug = register.tag(debug)
    440449
     
    538547do_for = register.tag("for", do_for)
    539548
    540549def do_ifequal(parser, token, negate):
    541     """
    542     Output the contents of the block if the two arguments equal/don't equal each other.
    543 
    544     Examples::
    545 
    546         {% ifequal user.id comment.user_id %}
    547             ...
    548         {% endifequal %}
    549 
    550         {% ifnotequal user.id comment.user_id %}
    551             ...
    552         {% else %}
    553             ...
    554         {% endifnotequal %}
    555     """
    556550    bits = list(token.split_contents())
    557551    if len(bits) != 3:
    558552        raise TemplateSyntaxError, "%r takes two arguments" % bits[0]
     
    568562
    569563#@register.tag
    570564def ifequal(parser, token):
     565    """
     566    Output the contents of the block if the two arguments equal each other.
     567
     568    Examples::
     569
     570        {% ifequal user.id comment.user_id %}
     571            ...
     572        {% endifequal %}
     573
     574        {% ifnotequal user.id comment.user_id %}
     575            ...
     576        {% else %}
     577            ...
     578        {% endifnotequal %}
     579    """
    571580    return do_ifequal(parser, token, False)
    572581ifequal = register.tag(ifequal)
    573582
    574583#@register.tag
    575584def ifnotequal(parser, token):
     585    """Output the contents of the block if the two arguments are not equal. See ifequal"""
    576586    return do_ifequal(parser, token, True)
    577587ifnotequal = register.tag(ifnotequal)
    578588
     
    889899
    890900def url(parser, token):
    891901    """
    892     Returns an absolute URL matching given view with its parameters. This is a
    893     way to define links that aren't tied to a particular url configuration:
     902    Returns an absolute URL matching given view with its parameters.
    894903   
     904    This is a way to define links that aren't tied to a particular url configuration::
     905   
    895906        {% url path.to.some_view arg1,arg2,name1=value1 %}
    896907   
    897908    The first argument is a path to a view. It can be an absolute python path
     
    901912    URL. All arguments for the URL should be present.
    902913
    903914    For example if you have a view ``app_name.client`` taking client's id and
    904     the corresponding line in a urlconf looks like this:
     915    the corresponding line in a urlconf looks like this::
    905916   
    906917        ('^client/(\d+)/$', 'app_name.client')
    907918   
    908919    and this app's urlconf is included into the project's urlconf under some
    909     path:
     920    path::
    910921   
    911922        ('^clients/', include('project_name.app_name.urls'))
    912923   
    913     then in a template you can create a link for a certain client like this:
     924    then in a template you can create a link for a certain client like this::
    914925   
    915926        {% url app_name.client client.id %}
    916927   
Back to Top