jinja2 Engine for tornado web framework
Project description
Integrate Jinja2 into Tornado Framework
=======================================
This package makes you have the ability that using Jiaja2 Template Engine with Tornado Web Framework.
It will replace the default Tornado Templates.
How to use:
-----------
Import Jinja2Loader to your project
.. code-block:: python
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.
.. code-block:: python
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)
.. _Loader: http://jinja.pocoo.org/docs/dev/api/#loaders
.. _environment: http://jinja.pocoo.org/docs/dev/api/#jinja2.Environment
=======================================
This package makes you have the ability that using Jiaja2 Template Engine with Tornado Web Framework.
It will replace the default Tornado Templates.
How to use:
-----------
Import Jinja2Loader to your project
.. code-block:: python
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.
.. code-block:: python
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)
.. _Loader: http://jinja.pocoo.org/docs/dev/api/#loaders
.. _environment: http://jinja.pocoo.org/docs/dev/api/#jinja2.Environment
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
tornado_jinja2-0.2.3.tar.gz
(4.4 kB
view hashes)
Built Distribution
Close
Hashes for tornado_jinja2-0.2.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30fd88f66adda74e4537b01f6447d836846a14452d53415bcb3a0e97bb874cdc |
|
MD5 | 60416f4fcb83ded866f542e04c02020e |
|
BLAKE2b-256 | f421ad37395be09e2b35dd19c1eadfb532570a5f8362e838ea8d651a5269becf |