<s> """<STR_LIT>""" <EOL> import os <EOL> from flask import request , current_app as app <EOL> from pystache . renderer import Renderer <EOL> def _get_renderer ( append = None ) : <EOL> append = append or [ ] <EOL> bp = app . blueprints . get ( request . blueprint , None ) <EOL> if not bp or not bp . template_folder : <EOL> dirs = [ os . path . join ( app . import_name , app . template_folder , * append ) ] <EOL> else : <EOL> path = bp . import_name . split ( '<STR_LIT:.>' ) + [ bp . template_folder ] <EOL> dirs = [ os . path . join ( * path + append ) ] <EOL> return Renderer ( search_dirs = dirs ) <EOL> def render_view ( view ) : <EOL> """<STR_LIT>""" <EOL> return _get_renderer ( ) . render ( view ) <EOL> def render_template ( template , ** context ) : <EOL> """<STR_LIT>""" <EOL> parts = template . split ( '<STR_LIT:/>' ) <EOL> renderer = _get_renderer ( parts [ : - <NUM_LIT:1> ] ) <EOL> return renderer . render ( renderer . load_template ( parts [ - <NUM_LIT:1> : ] [ <NUM_LIT:0> ] ) , context ) </s>
