Changeset 7089 for django/trunk/django/template/loader_tags.py
- Timestamp:
- 02/05/08 17:41:48 (1 year ago)
- Files:
-
- django/trunk/django/template/loader_tags.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/template/loader_tags.py
r7085 r7089 70 70 def render(self, context): 71 71 compiled_parent = self.get_parent(context) 72 if len(compiled_parent.nodelist) > 1: 73 n0, n1 = compiled_parent.nodelist[:2] 74 else: 75 n0, n1 = compiled_parent.nodelist[0], None 76 parent_is_child = (isinstance(n0, ExtendsNode) or 77 (isinstance(n0, TextNode) and isinstance(n1, ExtendsNode))) 78 if parent_is_child: 79 extend_node = int(not isinstance(n0, ExtendsNode)) 72 pos = 0 73 while isinstance(compiled_parent.nodelist[pos], TextNode): 74 pos += 1 75 parent_is_child = isinstance(compiled_parent.nodelist[pos], ExtendsNode) 80 76 parent_blocks = dict([(n.name, n) for n in compiled_parent.nodelist.get_nodes_by_type(BlockNode)]) 81 77 for block_node in self.nodelist.get_nodes_by_type(BlockNode): … … 89 85 # it'll be checked when the parent node's render() is called. 90 86 if parent_is_child: 91 compiled_parent.nodelist[ extend_node].nodelist.append(block_node)87 compiled_parent.nodelist[pos].nodelist.append(block_node) 92 88 else: 93 89 # Keep any existing parents and add a new one. Used by BlockNode.
