Ticket #3696: defaulttags.diff
File defaulttags.diff, 3.1 KB (added by , 18 years ago) |
---|
-
django_src/django/template/defaulttags.py
435 435 cycle = register.tag(cycle) 436 436 437 437 def 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 """ 438 447 return DebugNode() 439 448 debug = register.tag(debug) 440 449 … … 538 547 do_for = register.tag("for", do_for) 539 548 540 549 def 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 """556 550 bits = list(token.split_contents()) 557 551 if len(bits) != 3: 558 552 raise TemplateSyntaxError, "%r takes two arguments" % bits[0] … … 568 562 569 563 #@register.tag 570 564 def 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 """ 571 580 return do_ifequal(parser, token, False) 572 581 ifequal = register.tag(ifequal) 573 582 574 583 #@register.tag 575 584 def ifnotequal(parser, token): 585 """Output the contents of the block if the two arguments are not equal. See ifequal""" 576 586 return do_ifequal(parser, token, True) 577 587 ifnotequal = register.tag(ifnotequal) 578 588 … … 889 899 890 900 def url(parser, token): 891 901 """ 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. 894 903 904 This is a way to define links that aren't tied to a particular url configuration:: 905 895 906 {% url path.to.some_view arg1,arg2,name1=value1 %} 896 907 897 908 The first argument is a path to a view. It can be an absolute python path … … 901 912 URL. All arguments for the URL should be present. 902 913 903 914 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:: 905 916 906 917 ('^client/(\d+)/$', 'app_name.client') 907 918 908 919 and this app's urlconf is included into the project's urlconf under some 909 path: 920 path:: 910 921 911 922 ('^clients/', include('project_name.app_name.urls')) 912 923 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:: 914 925 915 926 {% url app_name.client client.id %} 916 927