Changeset 7688
- Timestamp:
- 06/18/08 07:59:39 (5 months ago)
- Files:
-
- django/trunk/django/template/loader_tags.py (modified) (2 diffs)
- django/trunk/tests/regressiontests/templates/tests.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/template/loader_tags.py
r7089 r7688 70 70 def render(self, context): 71 71 compiled_parent = self.get_parent(context) 72 pos = 073 while isinstance(compiled_parent.nodelist[pos], TextNode):74 pos += 175 parent_is_child = isinstance(compiled_parent.nodelist[pos], ExtendsNode)76 72 parent_blocks = dict([(n.name, n) for n in compiled_parent.nodelist.get_nodes_by_type(BlockNode)]) 77 73 for block_node in self.nodelist.get_nodes_by_type(BlockNode): … … 84 80 # add this BlockNode to the parent's ExtendsNode nodelist, so 85 81 # it'll be checked when the parent node's render() is called. 86 if parent_is_child: 87 compiled_parent.nodelist[pos].nodelist.append(block_node) 82 83 # Find out if the parent template has a parent itself 84 for node in compiled_parent.nodelist: 85 if not isinstance(node, TextNode): 86 # If the first non-text node is an extends, handle it. 87 if isinstance(node, ExtendsNode): 88 node.nodelist.append(block_node) 89 # Extends must be the first non-text node, so once you find 90 # the first non-text node you can stop looking. 91 break 88 92 else: 89 93 # Keep any existing parents and add a new one. Used by BlockNode. django/trunk/tests/regressiontests/templates/tests.py
r7565 r7688 705 705 'inheritance25': ("{% extends context_template.1 %}{% block first %}2{% endblock %}{% block second %}4{% endblock %}", {'context_template': [template.Template("Wrong"), template.Template("1{% block first %}_{% endblock %}3{% block second %}_{% endblock %}")]}, '1234'), 706 706 707 # Set up a base template to extend 708 'inheritance26': ("no tags", {}, 'no tags'), 709 710 # Inheritance from a template that doesn't have any blocks 711 'inheritance27': ("{% extends 'inheritance26' %}", {}, 'no tags'), 712 707 713 ### I18N ################################################################## 708 714
