Mako renderer for lribeiro.cherrypy.templating
Homepage Repository PyPI Python
pip install lribeiro.cherrypy.templating.mako==1.0
Mako renderer for lribeiro.cherrypy.templating
It has two optional config entries:
{root directory}/templates
is used.Developed under Python3.4 and tested against Python2.7, Python3.4 and pypy.
import cherrypy
from lribeiro.cherrypy.templating import template
from lribeiro.cherrypy.templating.mako import renderer
class Root(object):
@cherrypy.expose
@template('index.html')
def index(self):
return {'context': 'variables'}
@cherrypy.expose
@template('/page.html')
def page(self):
return {'context': 'variables'}
config = {
'/': {
'templating.renderer': renderer,
'templating.mako.template_directories': 'mako_templates', # optional
'templating.mako.config': {'module_directory': '/tmp/modules'} # also optional
}
}
if __name__ == '__main__':
cherrypy.quickstart(Root(), '/', config)