client_template_demo / template_demo /

from pyramid.asset import abspath_from_asset_spec
from mako.lookup import TemplateLookup
import re

class MakoRenderer(object):
    def __init__(self, info):
        package_name = info.package.__name__
        self.lookup = TemplateLookup(
                                "%s:templates" % package_name
        self.template_reg = re.compile(

    def __call__(self, value, system):
        return self._render(system['renderer_name'], data=value)

    def _render(self, tname, **kw):
        fname, defname, ext = self.template_reg.match(
                                        "fname", "defname", "extension"
        template = self.lookup.get_template("%s.%s" % (fname, ext))
        if defname:
            template = template.get_def(defname)
        return template.render_unicode(**kw)

class HandlebarsRenderer(MakoRenderer):
    def __call__(self, value, system):
        return super(HandlebarsRenderer, self)._render(

#class UIRenderer(object):
#    def __init__(self, info):
#        self.renderer = zpt_renderer_factory(RendererHelper(
#            '', brac2.views, info.registry))
#    def __call__(self, value, system):
#        request = system['request']
#        admin_user = request.admin_user
#        resource_types = [
#            {'title':,
#             'href': request.route_url('resource_type_list',,
#             'api': request.route_url('resource_type_api',,
#             'template': 'resource_type'}
#            for rt in request.dbsession.query(
#                ResourceType).order_by(]
#        return self.renderer(
#            {
#             'api': json.dumps(api_links(request)),
#             'data': json.dumps(value, sort_keys=True, indent=4),
#             'template':,
#             'resource_types': resource_types,
#             'login': authenticated_userid(request),
#             'adminuser': admin_user.is_admin if admin_user else False,
#            },
#            system)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.