Ticket #7318: fix-extends-tag.patch

File fix-extends-tag.patch, 2.1 KB (added by Matthias Kestenholz, 16 years ago)
  • AUTHORS

    diff --git a/AUTHORS b/AUTHORS
    index bb77b68..e2410ad 100644
    a b answer newbie questions, and generally made Django that much better:  
    387387    ymasuda@ethercube.com
    388388    Jarek Zgoda <jarek.zgoda@gmail.com>
    389389    Cheng Zhang
     390    Matthias Kestenholz <mk@spinlock.ch>
    390391
    391392A big THANK YOU goes to:
    392393
  • django/template/loader_tags.py

    diff --git a/django/template/loader_tags.py b/django/template/loader_tags.py
    index 00ae99b..59955d3 100644
    a b class ExtendsNode(Node):  
    7070    def render(self, context):
    7171        compiled_parent = self.get_parent(context)
    7272        pos = 0
    73         while isinstance(compiled_parent.nodelist[pos], TextNode):
     73        # Prevent an IndexError when parent consists only of TextNodes
     74        length = len(compiled_parent.nodelist)
     75        while pos<length-1 and isinstance(compiled_parent.nodelist[pos], TextNode):
    7476            pos += 1
    7577        parent_is_child = isinstance(compiled_parent.nodelist[pos], ExtendsNode)
    7678        parent_blocks = dict([(n.name, n) for n in compiled_parent.nodelist.get_nodes_by_type(BlockNode)])
  • tests/regressiontests/templates/tests.py

    diff --git a/tests/regressiontests/templates/tests.py b/tests/regressiontests/templates/tests.py
    index 4effea5..c474018 100644
    a b class Templates(unittest.TestCase):  
    704704            # Inheritance from local context with variable parent template
    705705            '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'),
    706706
     707            # Template with no tags
     708            'inheritance26': ("no tags", {}, 'no tags'),
     709
     710            # Inheritance from a template without tags
     711            'inheritance27': ("{% extends 'inheritance26' %}", {}, 'no tags'),
     712
    707713            ### I18N ##################################################################
    708714
    709715            # {% spaceless %} tag
Back to Top