#NEWLINE# def render_string_template( template_string , context = None , context_instance = None ) : #NEWLINE# #INDENT# '\n    Performs rendering using template_string instead of a file, and context.\n    context_instance is only used to feed user into context (unless already defined)\n\n    Returns string.\n    ' #NEWLINE# if ( context is None ) : #NEWLINE# #INDENT# context = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# template = Template ( template_string ) #NEWLINE# if ( ( 'user' not in context ) and context_instance ) : #NEWLINE# #INDENT# if ( 'request' in context_instance ) : #NEWLINE# #INDENT# context . update ( { #NEWLINE# #INDENT# 'user' : template_string [ 'request' ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# #UNINDENT# return template . render ( context )