#NEWLINE# def jst( request ) : #NEWLINE# #INDENT# '\n    Compile JST templates into a javascript module.\n    ' #NEWLINE# templates_path = os . path . join ( settings . SITE_ROOT , 'client/static/templates' ) #NEWLINE# compiled = '' #NEWLINE# for ( dirpath , dirnames , filenames ) in os . walk ( templates_path ) : #NEWLINE# #INDENT# for filename in filenames : #NEWLINE# #INDENT# ( name , extension ) = os . path . splitext ( filename ) #NEWLINE# if ( extension != '.jst' ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# fullpath = os . path . join ( dirpath , filename ) #NEWLINE# with open ( fullpath , 'r' ) as f : #NEWLINE# #INDENT# contents = f . read ( ) #NEWLINE# #UNINDENT# contents = re . sub ( '\\r?\\n' , '' , contents ) #NEWLINE# contents = re . sub ( "'" , "\\'" , contents ) #NEWLINE# compiled += ( "PANDA.templates['%s'] = _.template('%s');\n" % ( name , contents ) ) #NEWLINE# #UNINDENT# #UNINDENT# return HttpResponse ( compiled , mimetype = 'text/javascript' )