#NEWLINE# def render_genshi_tmpl( tmplstr , context , tmplpath = None ) : #NEWLINE# #INDENT# '\n    Render a Genshi template. A method should be passed in as part of the\n    context. If no method is passed in, xml is assumed. Valid methods are:\n\n    .. code-block:\n\n        - xml\n        - xhtml\n        - html\n        - text\n        - newtext\n        - oldtext\n\n    Note that the ``text`` method will call ``NewTextTemplate``. If ``oldtext``\n    is desired, it must be called explicitly\n    ' #NEWLINE# method = context . get ( 'method' , 'xml' ) #NEWLINE# if ( ( method == 'text' ) or ( method == 'newtext' ) ) : #NEWLINE# #INDENT# from genshi.template import NewTextTemplate #NEWLINE# tmpl = NewTextTemplate ( tmplstr ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( method == 'oldtext' ) : #NEWLINE# #INDENT# from genshi.template import OldTextTemplate #NEWLINE# tmpl = OldTextTemplate ( tmplstr ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# from genshi.template import MarkupTemplate #NEWLINE# tmpl = MarkupTemplate ( tmplstr ) #NEWLINE# #UNINDENT# #UNINDENT# return tmpl . generate ( ** context ) . render ( method )