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<http://jinja.pocoo.org/docs/dev/api/#loaders>`_ from jinja2 and configuring jinaja2 `environment <http://jinja.pocoo.org/docs/dev/api/#jinja2.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)
=======================================
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<http://jinja.pocoo.org/docs/dev/api/#loaders>`_ from jinja2 and configuring jinaja2 `environment <http://jinja.pocoo.org/docs/dev/api/#jinja2.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)
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.2.tar.gz
(4.4 kB
view hashes)
Built Distribution
Close
Hashes for tornado_jinja2-0.2.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 179f87ff4b2716c6e2d5bc3b4fe25719659bf234b1fa219f0f080d35d2e0cf5a |
|
MD5 | fd4354b6f675af174639e095471d4800 |
|
BLAKE2b-256 | 5972afa90f092c52b3ddeb5479aa24bd0b263f4a6fef3d0d7147bcc601bd4add |