- Now its time to switch gears and use the best of the breed, aka mako. Just by looking at pypi you can see that mako is 0.7.0 was downloaded 64,000 times while chameleon (repoze.org creation) a default templating for pyramid 13,000. If you have also developed with turbogears for over 3 years you know the version 1 had Kid and version 2 had genshi. While Genshi(created by people who created trac) would probably be your best option, mako has been around for a while and its fully enabled in pyramid,turbogears, etc. We will use mako from now on.
Enabled Mako in pyramid
- Mako is enabled already but the path to template folder needs to be defined a little differently.
@view_config(route_name='home', renderer='templates/mytemplate.pt') #to @view_config(route_name='home', renderer='myapp:templates/mytemplate.mak')
Where myapp is the package name you have created.
- The alternative is to add this to your development.ini (and later production.ini)
Edit development.ini and add this line
mako.directories = myapp:templates
Now inside the view.py you can use:
@view_config(route_name='home', renderer='templates/mytemplate.pt') #to @view_config(route_name='home', renderer='mytemplate.mak')
- Rename mytemplate.pt to mytemplate.mak for now, so that it works.