Pyramid framework tips : Mako Templates settings

mako templates pyramid framework

In Pyramid framework you can use the mako templates.

In development.ini and production.ini:

# mako template settings
mako.directories = YOUR_PROJECT_NAME:templates

It is better to save your mako files with *.html if you use html editors or Eclipse / Aptana.
For *.html you must add pyramid mako renderer factory in Pyramid Application in

def main(global_config, **settings):
  """ This function returns a Pyramid WSGI application.
  # mako settings for file extension .html
  config.add_renderer(".html", "pyramid.mako_templating.renderer_factory")

If you are not adding mako templating renderer factory, you get this error:
ValueError: No such renderer factory .html

Leave a Reply