Ticket #5124: must_be_first.diff
File must_be_first.diff, 1.6 KB (added by , 17 years ago) |
---|
-
django/template/__init__.py
311 311 return NodeList() 312 312 313 313 def extend_nodelist(self, nodelist, node, token): 314 if node.must_be_first and len(nodelist): 315 raise TemplateSyntaxError, "%r must be the first Node on the template." % node 314 316 nodelist.append(node) 315 317 316 318 def enter_command(self, command, token): … … 780 782 return current 781 783 782 784 class Node(object): 785 # Set this to True if the node must be the first on a NodeList. 786 must_be_first = False 787 783 788 def render(self, context): 784 789 "Return the node rendered as a string" 785 790 pass -
django/template/loader_tags.py
37 37 self.parent = BlockNode(self.name, nodelist) 38 38 39 39 class ExtendsNode(Node): 40 must_be_first = True 41 40 42 def __init__(self, nodelist, parent_name, parent_name_expr, template_dirs=None): 41 43 self.nodelist = nodelist 42 44 self.parent_name, self.parent_name_expr = parent_name, parent_name_expr 43 45 self.template_dirs = template_dirs 44 46 47 def __repr__(self): 48 return '<ExtendsNode: %s>' % self.parent_name 49 45 50 def get_parent(self, context): 46 51 if self.parent_name_expr: 47 52 self.parent_name = self.parent_name_expr.resolve(context)