Ticket #6232: 6232.diff
File 6232.diff, 2.7 KB (added by , 17 years ago) |
---|
-
django/template/defaulttags.py
163 163 def __init__(self, nodelist, *varlist): 164 164 self.nodelist = nodelist 165 165 self._last_seen = None 166 self._varlist = map(Variable, varlist)166 self._varlist = varlist 167 167 168 168 def render(self, context): 169 169 if 'forloop' in context and context['forloop']['first']: … … 805 805 bits = token.contents.split() 806 806 nodelist = parser.parse(('endifchanged',)) 807 807 parser.delete_first_token() 808 return IfChangedNode(nodelist, *bits[1:]) 808 varlist = [parser.compile_filter(bit) for bit in bits[1:]] 809 return IfChangedNode(nodelist, *varlist) 809 810 ifchanged = register.tag(ifchanged) 810 811 811 812 #@register.tag -
tests/regressiontests/templates/tests.py
552 552 # Test a date+hour like construct, where the hour of the last day 553 553 # is the same but the date had changed, so print the hour anyway. 554 554 'ifchanged-param04': ('{% for d in days %}{% ifchanged %}{{ d.day }}{% endifchanged %}{% for h in d.hours %}{% ifchanged d h %}{{ h }}{% endifchanged %}{% endfor %}{% endfor %}', {'days':[{'day':1, 'hours':[1,2,3]},{'day':2, 'hours':[3]},] }, '112323'), 555 556 555 # Logically the same as above, just written with explicit 557 556 # ifchanged for the day. 558 'ifchanged-param0 4': ('{% for d in days %}{% ifchanged d.day %}{{ d.day }}{% endifchanged %}{% for h in d.hours %}{% ifchanged d.day h %}{{ h }}{% endifchanged %}{% endfor %}{% endfor %}', {'days':[{'day':1, 'hours':[1,2,3]},{'day':2, 'hours':[3]},] }, '112323'),557 'ifchanged-param05': ('{% for d in days %}{% ifchanged d.day %}{{ d.day }}{% endifchanged %}{% for h in d.hours %}{% ifchanged d.day h %}{{ h }}{% endifchanged %}{% endfor %}{% endfor %}', {'days':[{'day':1, 'hours':[1,2,3]},{'day':2, 'hours':[3]},] }, '112323'), 559 558 559 # Variables passed to ifchanged can have filters. 560 'ifchanged-param06': ('{% for f in floats %}{% ifchanged f|floatformat:2 %}{{ f }}--{% endifchanged %}{% endfor %}', {'floats': [1.1, 1.1, 1.3, 1.305, 1.4] }, '1.1--1.3--1.4--'), 561 560 562 ### IFEQUAL TAG ########################################################### 561 563 'ifequal01': ("{% ifequal a b %}yes{% endifequal %}", {"a": 1, "b": 2}, ""), 562 564 'ifequal02': ("{% ifequal a b %}yes{% endifequal %}", {"a": 1, "b": 1}, "yes"),