#NEWLINE# def cache_key( self , template_name , template_dirs , skip = None ) : #NEWLINE# #INDENT# '\n        Generate a cache key for the template name, dirs, and skip.\n\n        If skip is provided, only origins that match template_name are included\n        in the cache key. This ensures each template is only parsed and cached\n        once if contained in different extend chains like:\n\n            x -> a -> a\n            y -> a -> a\n            z -> a -> a\n        ' #NEWLINE# dirs_prefix = '' #NEWLINE# skip_prefix = '' #NEWLINE# if skip : #NEWLINE# #INDENT# matching = [ origin . name for origin in skip if ( origin . template_name == template_name ) ] #NEWLINE# if matching : #NEWLINE# #INDENT# skip_prefix = self . generate_hash ( matching ) #NEWLINE# #UNINDENT# #UNINDENT# if template_dirs : #NEWLINE# #INDENT# dirs_prefix = self . generate_hash ( template_dirs ) #NEWLINE# #UNINDENT# return '-' . join ( filter ( bool , [ template_name , skip_prefix , dirs_prefix ] ) )