#NEWLINE# def visit_Extends( self , node , frame ) : #NEWLINE# #INDENT# 'Calls the extender.' #NEWLINE# if ( not frame . toplevel ) : #NEWLINE# #INDENT# self . fail ( 'cannot use extend from a non top-level scope' , node . lineno ) #NEWLINE# #UNINDENT# if ( self . extends_so_far > 0 ) : #NEWLINE# #INDENT# if ( not self . has_known_extends ) : #NEWLINE# #INDENT# self . writeline ( 'if parent_template is not None:' ) #NEWLINE# self . indent ( ) #NEWLINE# #UNINDENT# self . writeline ( ( 'raise TemplateRuntimeError(%r)' % 'extended multiple times' ) ) #NEWLINE# if self . has_known_extends : #NEWLINE# #INDENT# raise CompilerExit ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . outdent ( ) #NEWLINE# #UNINDENT# #UNINDENT# self . writeline ( 'parent_template = environment.get_template(' , node ) #NEWLINE# self . visit ( node . template , frame ) #NEWLINE# self . write ( ( ', %r)' % self . name ) ) #NEWLINE# self . writeline ( ( 'for name, parent_block in parent_template.blocks.%s():' % dict_item_iter ) ) #NEWLINE# self . indent ( ) #NEWLINE# self . writeline ( 'context.blocks.setdefault(name, []).append(parent_block)' ) #NEWLINE# self . outdent ( ) #NEWLINE# if frame . rootlevel : #NEWLINE# #INDENT# self . has_known_extends = True #NEWLINE# #UNINDENT# self . extends_so_far += 1