Edit me on GitHub

pyramid_jinja2 API

pyramid_jinja2.includeme(config)

Set up standard configurator registrations. Use via:

config = Configurator()
config.include('pyramid_jinja2')

Once this function has been invoked, the .jinja2 renderer is available for use in Pyramid and these new directives are available as methods of the configurator:

  • add_jinja2_search_path: Add a search path location to the search path.
  • add_jinja2_extension: Add a list of extensions to the Jinja2 environment.
  • get_jinja2_environment``: Return the Jinja2 environment.Environment used by pyramid_jinja2.
pyramid_jinja2.add_jinja2_search_path(config, searchpath)

This function is added as a method of a Configurator, and should not be called directly. Instead it should be called like so after pyramid_jinja2 has been passed to config.include:

config.add_jinja2_search_path('anotherpackage:templates/')

It will add the directory or asset spec passed as searchpath to the current search path of the jinja2.environment.Environment used by pyramid_jinja2.

pyramid_jinja2.add_jinja2_extension(config, ext)

This function is added as a method of a Configurator, and should not be called directly. Instead it should be called like so after pyramid_jinja2 has been passed to config.include:

config.add_jinja2_extension(myext)

It will add the Jinja2 extension passed as ext to the current jinja2.environment.Environment used by pyramid_jinja2.

pyramid_jinja2.get_jinja2_environment(config)

This function is added as a method of a Configurator, and should not be called directly. Instead it should be called like so after pyramid_jinja2 has been passed to config.include:

config.get_jinja2_environment()

It will return the current jinja2.environment.Environment used by pyramid_jinja2 or None if no environment has yet been set up.

class pyramid_jinja2.Jinja2TemplateRenderer(info, environment)

Renderer for a jinja2 template

class pyramid_jinja2.SmartAssetSpecLoader(searchpath=(), encoding='utf-8', debug=False)

A Jinja2 template loader that knows how to handle asset specifications.

Previous topic

Glossary