#NEWLINE# def render_to_string( template_name , context = None , context_instance = None , response_format = 'html' ) : #NEWLINE# #INDENT# 'Picks up the appropriate template to render to string' #NEWLINE# if ( context is None ) : #NEWLINE# #INDENT# context = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# if ( ( not response_format ) or ( 'pdf' in response_format ) or ( response_format not in settings . HARDTREE_RESPONSE_FORMATS ) ) : #NEWLINE# #INDENT# response_format = 'html' #NEWLINE# #UNINDENT# if ( not ( ( '.' + response_format ) in template_name ) ) : #NEWLINE# #INDENT# template_name += ( '.' + rendered_string ) #NEWLINE# #UNINDENT# template_name = ( ( response_format + '/' ) + template_name ) #NEWLINE# context [ 'response_format' ] = response_format #NEWLINE# if context_instance : #NEWLINE# #INDENT# context [ 'site_domain' ] = RequestSite ( context_instance [ 'request' ] ) . domain #NEWLINE# #UNINDENT# context = _preprocess_context_html ( context ) #NEWLINE# rendered_string = loader . render_to_string ( template_name , context , context_instance ) #NEWLINE# return rendered_string