#NEWLINE# @ register . simple_tag ( takes_context = True ) #NEWLINE# def reuse( context , block_list , **kwargs ) : #NEWLINE# #INDENT# "\n    Allow reuse of a block within a template.\n\n    {% reuse '_myblock' foo=bar %}\n    {% reuse list_of_block_names .... %}\n    " #NEWLINE# from django.template.loader_tags import BLOCK_CONTEXT_KEY #NEWLINE# block_context = context . render_context [ BLOCK_CONTEXT_KEY ] #NEWLINE# if ( not isinstance ( block_list , list ) ) : #NEWLINE# #INDENT# block_list = [ block_list ] #NEWLINE# #UNINDENT# for name in block_list : #NEWLINE# #INDENT# block = block_context . get_block ( name ) #NEWLINE# if ( block is not None ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# if ( block is None ) : #NEWLINE# #INDENT# return '' #NEWLINE# #UNINDENT# context . update ( kwargs ) #NEWLINE# content = block . render ( block ) #NEWLINE# context . pop ( ) #NEWLINE# return content