https://github.com/rcmachado/tomako
Tornado + Mako
https://github.com/rcmachado/tomako
Last synced: about 2 months ago
JSON representation
Tornado + Mako
- Host: GitHub
- URL: https://github.com/rcmachado/tomako
- Owner: rcmachado
- License: mit
- Created: 2013-03-26T00:00:56.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2016-06-30T17:21:42.000Z (almost 9 years ago)
- Last Synced: 2025-03-20T06:35:16.096Z (3 months ago)
- Language: Python
- Size: 8.79 KB
- Stars: 6
- Watchers: 1
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
Tornado + Mako = tomako
=======================Tomako is a tiny library designed to provide an easy way to use Mako
as a template engine for Tornado.This lib was tested with Tornado 2.3/2.4 and Mako 0.7.2, but should
work in other versions - although it wasn't tested in other versions.Usage
-----The recommended approach is to pass ``template_loader`` configuration
to ``Application`` class... code-block:: python
from tomako import MakoTemplateLoader
conf = {
'template_loader': MakoTemplateLoader('/full/template/path')
}
app = Application(urls, **conf)If you can't for any reason modify the ``template_loader``
configuration or you want to use Mako as a template engine only on
some handlers, you can overwrite ``RequestHandler.create_template_loader``... code-block:: python
from tornado.web import RequestHandler
from tomako import MakoTemplateLoaderclass MyHandler(RequestHandler):
def create_template_loader(self, template_path):
return MakoTemplateLoader(template_path)Tornado UIModules
-----------------Tomako has basic support for Tornado's UIModules_. You must include a
special namespace called ``tomako.template`` in your templates:.. code-block:: python
# Your python file
from tornado.web import UIModuleclass MyModule(UIModule):
def render(self, arg1, arg2):
# do something with args here...
return 'some string'.. code-block:: html
<%namespace name="tomako" module="tomako.template" /><%tomako:ui uiclass="your.project.module.MyModule" arg1="value1" arg2="value2" />
Install
-------.. code-block:: shell
pip install tomako
To-Do
-----* Improve support on UIModules
License
-------This work is licensed under MIT license (see LICENSE file).
.. _UIModules: http://www.tornadoweb.org/en/stable/overview.html#ui-modules