Changeset 7082
- Timestamp:
- 02/03/08 20:31:53 (10 months ago)
- Files:
-
- django/trunk/django/template/loader_tags.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/template/loader_tags.py
r6673 r7082 1 1 from django.template import TemplateSyntaxError, TemplateDoesNotExist, Variable 2 from django.template import Library, Node 2 from django.template import Library, Node, TextNode 3 3 from django.template.loader import get_template, get_template_from_string, find_template_source 4 4 from django.conf import settings … … 63 63 def render(self, context): 64 64 compiled_parent = self.get_parent(context) 65 parent_is_child = isinstance(compiled_parent.nodelist[0], ExtendsNode) 65 if len(compiled_parent.nodelist) > 1: 66 n0, n1 = compiled_parent.nodelist[:2] 67 else: 68 n0, n1 = compiled_parent.nodelist[0], None 69 parent_is_child = (isinstance(n0, ExtendsNode) or 70 (isinstance(n0, TextNode) and isinstance(n1, ExtendsNode))) 71 if parent_is_child: 72 extend_node = int(not isinstance(n0, ExtendsNode)) 66 73 parent_blocks = dict([(n.name, n) for n in compiled_parent.nodelist.get_nodes_by_type(BlockNode)]) 67 74 for block_node in self.nodelist.get_nodes_by_type(BlockNode): … … 75 82 # it'll be checked when the parent node's render() is called. 76 83 if parent_is_child: 77 compiled_parent.nodelist[ 0].nodelist.append(block_node)84 compiled_parent.nodelist[extend_node].nodelist.append(block_node) 78 85 else: 79 86 # Keep any existing parents and add a new one. Used by BlockNode.
