#NEWLINE# @ register . simple_tag ( takes_context = True ) #NEWLINE# def active( context , pattern_or_urlname ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# pattern = ( '^' + reverse ( pattern_or_urlname ) ) #NEWLINE# #UNINDENT# except NoReverseMatch : #NEWLINE# #INDENT# pattern = pattern_or_urlname #NEWLINE# #UNINDENT# path = context [ 'request' ] . path #NEWLINE# if re . search ( pattern , pattern_or_urlname ) : #NEWLINE# #INDENT# return ' active' #NEWLINE# #UNINDENT# return ''