#NEWLINE# def tokenize( self ) : #NEWLINE# #INDENT# 'Return a list of tokens from a given template_string' #NEWLINE# ( result , upto ) = ( [ ] , 0 ) #NEWLINE# for match in tag_re . finditer ( self . template_string ) : #NEWLINE# #INDENT# ( start , end ) = match . span ( ) #NEWLINE# if ( start > upto ) : #NEWLINE# #INDENT# result . append ( self . create_token ( self . template_string [ upto : start ] , ( upto , start ) , False ) ) #NEWLINE# upto = start #NEWLINE# #UNINDENT# result . append ( self . create_token ( self . template_string [ start : end ] , ( start , end ) , True ) ) #NEWLINE# upto = end #NEWLINE# #UNINDENT# last_bit = self . template_string [ upto : ] #NEWLINE# if last_bit : #NEWLINE# #INDENT# result . append ( self . create_token ( last_bit , ( upto , ( upto + len ( last_bit ) ) ) , False ) ) #NEWLINE# #UNINDENT# return result