Extensions — Jinja2 2.7.2 documentation

index next | previous | Jinja2 2.7.2 documentation » ¶ Jinja2 supports extensions that can add extra filters, tests, globals or even extend the parser. The main motivation of extensions is it to move often used code into a reusable class like adding support for internationalization. ¶ Extensions are added to the Jinja2 environment at creation time. Once the environment is created additional extensions cannot be added. To add an extension pass a list of extension classes or import paths to the environment parameter of the Environment constructor. The following example creates a Jinja2 environment with the i18n extension loaded: jinja_env = Environment ( extensions = [ 'jinja2.ext.i18n' ]) ¶ Import name: jinja2.ext.i18n Jinja2 currently comes with one extension, the i18n extension. It can be used in combination with gettext or babel . If the i18n extens...

Linked on 2014-04-14 18:46:09 | Similar Links