Ticket #6296: 6296.diff
File 6296.diff, 3.1 KB (added by , 17 years ago) |
---|
-
django/template/defaulttags.py
8 8 except NameError: 9 9 from django.utils.itercompat import reversed # Python 2.3 fallback 10 10 11 from django.template import Node, NodeList, Template, Context, Variable 11 from django.template import Node, NodeList, Template, Context, Variable, FilterExpression 12 12 from django.template import TemplateSyntaxError, VariableDoesNotExist, BLOCK_TAG_START, BLOCK_TAG_END, VARIABLE_TAG_START, VARIABLE_TAG_END, SINGLE_BRACE_START, SINGLE_BRACE_END, COMMENT_TAG_START, COMMENT_TAG_END 13 13 from django.template import get_library, Library, InvalidTemplateLibrary 14 14 from django.conf import settings … … 188 188 return '' 189 189 190 190 class IfEqualNode(Node): 191 def __init__(self, var1, var2, nodelist_true, nodelist_false, negate ):192 self.var1, self.var2 = Variable(var1), Variable(var2)191 def __init__(self, var1, var2, nodelist_true, nodelist_false, negate, parser): 192 self.var1, self.var2 = FilterExpression(var1, parser), FilterExpression(var2, parser) 193 193 self.nodelist_true, self.nodelist_false = nodelist_true, nodelist_false 194 194 self.negate = negate 195 195 … … 647 647 parser.delete_first_token() 648 648 else: 649 649 nodelist_false = NodeList() 650 return IfEqualNode(bits[1], bits[2], nodelist_true, nodelist_false, negate )650 return IfEqualNode(bits[1], bits[2], nodelist_true, nodelist_false, negate, parser) 651 651 652 652 #@register.tag 653 653 def ifequal(parser, token): -
tests/regressiontests/templates/tests.py
570 570 'ifequal08': ('{% ifequal a "test" %}yes{% else %}no{% endifequal %}', {"a": "no"}, "no"), 571 571 'ifequal09': ('{% ifequal a "test" %}yes{% else %}no{% endifequal %}', {}, "no"), 572 572 'ifequal10': ('{% ifequal a b %}yes{% else %}no{% endifequal %}', {}, "yes"), 573 'ifequal11': ('{% ifequal a|first b %}yes{% else %}no{% endifequal %}',{"a": [1, 2], "b": 1}, "yes"), 574 'ifequal12': ('{% ifequal a|first b %}yes{% else %}no{% endifequal %}',{"a": [2, 1], "b": 1}, "no"), 575 'ifequal13': ('{% ifequal a|first b %}yes{% else %}no{% endifequal %}',{"a": ["django", "python"], "b": "django"}, "yes"), 576 'ifequal14': ('{% ifequal a|last "python" %}yes{% else %}no{% endifequal %}',{"a": ["django", "python"]}, "yes"), 573 577 574 578 # SMART SPLITTING 575 579 'ifequal-split01': ('{% ifequal a "test man" %}yes{% else %}no{% endifequal %}', {}, "no"), -
AUTHORS
351 351 ymasuda@ethercube.com 352 352 Jarek Zgoda <jarek.zgoda@gmail.com> 353 353 Cheng Zhang 354 Thejaswi Puthraya <thejaswi.puthraya@gmail.com> 354 355 355 356 A big THANK YOU goes to: 356 357