<s> from jinja2 import Environment , PackageLoader <EOL> import web <EOL> import json <EOL> import md5 <EOL> import markdown <EOL> env = Environment ( loader = PackageLoader ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> env . filters [ '<STR_LIT>' ] = json . dumps <EOL> env . filters [ '<STR_LIT>' ] = lambda s : md5 . md5 ( s ) . hexdigest ( ) <EOL> env . filters [ '<STR_LIT>' ] = web . datestr <EOL> env . filters [ '<STR_LIT>' ] = markdown . markdown <EOL> _context_processors = [ ] <EOL> def render_template ( _filename , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> template = env . get_template ( _filename ) <EOL> template_vars = _get_injected_vars ( ) <EOL> template_vars . update ( kwargs ) <EOL> return template . render ( ** template_vars ) <EOL> def _get_injected_vars ( ) : <EOL> if '<STR_LIT>' not in web . ctx : <EOL> d = { } <EOL> for cp in _context_processors : <EOL> d . update ( cp ( ) ) <EOL> web . ctx . injected_vars = d <EOL> return web . ctx . injected_vars <EOL> def context_processor ( f ) : <EOL> """<STR_LIT>""" <EOL> _context_processors . append ( f ) <EOL> return f </s>
