djinja2 /

Filename Size Date modified Message
21 B
1.1 KB
2.4 KB
Djinja2 is a package that provides integration for the Jinja2 template
language into the Django framework. Some features it has that other
Django/Jinja2 bridges don't include:

- A special ``Template`` class that automatically uses the global environment
- Both ``get_template`` and ``select_template``
- Integration with Django's cache system
- Built-in context processor support
- Reimplementations of some Django tags and filters
- Laziness - the environment is not created until needed

Pretty much, to use it, you need to just configure the settings and import
``get_template``, ``select_template``, or ``Template`` from the ``djinja2``
package. To use a request context, use ``djinja2.request_context`` (or
``djinja2.RequestContext`` for backwards-compatibility, though
``request_context`` is the preferred spelling).

The settings you can configure are:

    Additional options to send to the Jinja2 environment, in the form of a
    dictionary. (Futher settings will override this.) The default is ``{}``.
    A list or tuple of loader functions or paths to loader functions. These
    must take no arguments and return a single Jinja2 template loader to be
    searched in order. The default is ``('djinja2.loader.from_template_dirs',
    A list or tuple of directories containing Jinja2 templates to use. This
    is used by the ``djinja2.loader.from_template_dirs`` loader. If you use
    that loader (which is used by default), you MUST set this.
    If the ``djinja2.loader.from_app_directories`` loader is used, this is the
    directory within an application where a template would be used. It
    defaults to ``jinja2_templates``.
    This is actually a Django setting, and you should check the Django docs to
    see what to do. But the ``request_context`` function uses this just like
    Django's ``RequestContext`` does.
    If set, this must be a list of Jinja2 extension classes or the paths to
    those classes.
    If set to True, Djinja2 will cache bytecode using Django's caching
    system. If set to an instance of ``jinja2.BytecodeCache``, that will be
    used to cache the bytecode.

It's MIT/X11 licensed.