Ticket #6586: extend.2.patch

File extend.2.patch, 1.4 KB (added by fredd4@…, 17 years ago)

Previous patch has a bug. Here is a good one.

  • loader_tags.py

     
    4444        self.parent_name, self.parent_name_expr = parent_name, parent_name_expr
    4545        self.template_dirs = template_dirs
    4646
     47        if parent_name:
     48            self.compiled_parent = self.process_parent(None)
     49        else:
     50            self.compiled_parent = Non
     51
    4752    def __repr__(self):
    4853        if self.parent_name_expr:
    4954            return "<ExtendsNode: extends %s>" % self.parent_name_expr.token
     
    6772        else:
    6873            return get_template_from_string(source, origin, parent)
    6974
    70     def render(self, context):
     75    def process_parent( self, context ):
    7176        compiled_parent = self.get_parent(context)
    7277        pos = 0
    7378        while isinstance(compiled_parent.nodelist[pos], TextNode):
     
    9095                parent_block.parent = block_node.parent
    9196                parent_block.add_parent(parent_block.nodelist)
    9297                parent_block.nodelist = block_node.nodelist
     98        return compiled_parent
     99   
     100    def render(self, context):
     101        if self.compiled_parent:
     102            compiled_parent = self.compiled_parent
     103        else:
     104            compiled_parent = process_parent( self, context )
    93105        return compiled_parent.render(context)
    94106
    95107class ConstantIncludeNode(Node):
Back to Top