Skip to main content

Tomako is the easiest way to use Mako as a template engine for Tornado

Project description

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.

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.

from tornado.web import RequestHandler
from tomako import MakoTemplateLoader

class 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:

# Your python file
from tornado.web import UIModule

class MyModule(UIModule):
    def render(self, arg1, arg2):
        # do something with args here...
        return 'some string'
<!-- Your template -->
<%namespace name="tomako" module="tomako.template" />

<%tomako:ui uiclass="your.project.module.MyModule" arg1="value1" arg2="value2" />

Install

pip install tomako

To-Do

  • Improve support on UIModules

License

This work is licensed under MIT license (see LICENSE file).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tomako-0.1.0.post1.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

tomako-0.1.0.post1-py2.py3-none-any.whl (6.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file tomako-0.1.0.post1.tar.gz.

File metadata

File hashes

Hashes for tomako-0.1.0.post1.tar.gz
Algorithm Hash digest
SHA256 2d8ec113199408eb16ec00361aac6f10b716925779b6331083f304d01dafd150
MD5 a2e9e99be4ddf2263ed441ddc3dfcf96
BLAKE2b-256 3064e174248281cb2fa8f5bce955d4bd49b253e622bb540a6001e48dec378a07

See more details on using hashes here.

File details

Details for the file tomako-0.1.0.post1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for tomako-0.1.0.post1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ada4758833eb427ff9727fd15dbe9366cc86c65ea82e5f98e10c73acee50f557
MD5 7717f302d118a8ecc6f0f0fd87002374
BLAKE2b-256 b725f5b20574e4b20945220f9e6523275d18486edb4011dc4401c6ff6ad3ecd9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page