Skip to content

mr-ping/tornado_jinja2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Integrate Jinja2 template engine with Tornado web-framwork

Installing tonado-jinja2 from pypi:

pip install tornado-jinja2

Useage:

Import Jinja2Loader to your project

from tornado_jinja2 import Jinja2Loader

Pass the instance of Jinja2Loader to tornado.web.Application as the value of "template_loader" parameter.
You can use the particular Loader from jinja2 and configuring jinaja2 environment by your self.

import tornado.web
import jinja2

# Create a instance of Jinja2Loader
jinja2_env = jinja2.Environment(loader=jinja2.FileSystemLoader('template/path/'), autoescape=False)
jinja2_loader = Jinja2Loader(jinja2_env)

# Give it to Tornado to replace the default Loader.
settings = dict(template_loader=jinja2_loader)
application = tornado.web.Application(handler=[],
                                      **settings)

Testing

Execuse the command in the package directory

python -m test.test -v

About

Integrate jinja2 with tornado

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published