Ticket #11730: ifequal-template-bug.diff
File ifequal-template-bug.diff, 1.5 KB (added by , 15 years ago) |
---|
-
django/template/defaulttags.py
170 170 self._varlist = varlist 171 171 self._id = str(id(self)) 172 172 173 def __iter__(self): 174 for node in self.nodelist_true: 175 yield node 176 for node in self.nodelist_false: 177 yield node 178 179 def get_nodes_by_type(self, nodetype): 180 nodes = [] 181 if isinstance(self, nodetype): 182 nodes.append(self) 183 nodes.extend(self.nodelist_true.get_nodes_by_type(nodetype)) 184 nodes.extend(self.nodelist_false.get_nodes_by_type(nodetype)) 185 return nodes 186 173 187 def render(self, context): 174 188 if 'forloop' in context and self._id not in context['forloop']: 175 189 self._last_seen = None … … 202 216 def __repr__(self): 203 217 return "<IfEqualNode>" 204 218 219 def __iter__(self): 220 for node in self.nodelist_true: 221 yield node 222 for node in self.nodelist_false: 223 yield node 224 225 def get_nodes_by_type(self, nodetype): 226 nodes = [] 227 if isinstance(self, nodetype): 228 nodes.append(self) 229 nodes.extend(self.nodelist_true.get_nodes_by_type(nodetype)) 230 nodes.extend(self.nodelist_false.get_nodes_by_type(nodetype)) 231 return nodes 232 205 233 def render(self, context): 206 234 val1 = self.var1.resolve(context, True) 207 235 val2 = self.var2.resolve(context, True)