<s> from pyjade . ext . mako import preprocessor <EOL> try : <EOL> from pyramid_mako import MakoRendererFactory <EOL> from pyramid_mako import parse_options_from_settings <EOL> from pyramid_mako import PkgResourceTemplateLookup <EOL> is_pyramid_mako = True <EOL> except ImportError : <EOL> from pyramid import mako_templating <EOL> is_pyramid_mako = False <EOL> class PyjadeRenderer ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , info ) : <EOL> info . settings [ '<STR_LIT>' ] = preprocessor <EOL> self . makoRenderer = mako_templating . renderer_factory ( info ) <EOL> def __call__ ( self , value , system ) : <EOL> return self . makoRenderer ( value , system ) <EOL> def add_jade_renderer ( config , extension , mako_settings_prefix = '<STR_LIT>' ) : <EOL> renderer_factory = MakoRendererFactory ( ) <EOL> config . add_renderer ( extension , renderer_factory ) <EOL> def register ( ) : <EOL> settings = config . registry . settings <EOL> settings [ '<STR_LIT>' . format ( mako_settings_prefix ) ] = preprocessor <EOL> opts = parse_options_from_settings ( settings , mako_settings_prefix , config . maybe_dotted ) <EOL> lookup = PkgResourceTemplateLookup ( ** opts ) <EOL> renderer_factory . lookup = lookup <EOL> config . action ( ( '<STR_LIT>' , extension ) , register ) <EOL> def includeme ( config ) : <EOL> if not is_pyramid_mako : <EOL> config . add_renderer ( "<STR_LIT>" , renderer ) <EOL> else : <EOL> config . add_directive ( '<STR_LIT>' , add_jade_renderer ) <EOL> config . add_jade_renderer ( '<STR_LIT>' ) </s>
