module documentation

Classes for managing templates and their runtime and compile time options.

Class Environment The core component of Jinja is the `Environment`. It contains important shared variables like configuration, filters, tests, globals and others. Instances of this class may be modified if they are not shared and if no template was loaded so far...
Class Template A compiled template that can be rendered.
Class TemplateExpression The :meth:`jinja2.Environment.compile_expression` method returns an instance of this object. It encapsulates the expression-like access to the template with an expression it wraps.
Class TemplateModule Represents an imported template. All the exported names of the template are available as attributes on this object. Additionally converting it into a string renders the contents.
Class TemplateStream A template stream works pretty much like an ordinary python generator but it can buffer multiple items to reduce the number of total iterations. Per default the output is unbuffered which means that for every unbuffered instruction in the template one string is yielded.
Function copy_cache Create an empty copy of the given cache.
Function create_cache Return the cache class for the given size.
Function get_spontaneous_environment Return a new spontaneous environment. A spontaneous environment is used for templates created directly rather than through an existing environment.
Function load_extensions Load the extensions from the list and bind it to the environment. Returns a dict of instantiated extensions.
Function _environment_config_check Perform a sanity check on the environment.
Variable _env_bound Undocumented
def copy_cache(cache): (source)

Create an empty copy of the given cache.

Parameters
cache:t.Optional[t.MutableMapping]Undocumented
Returns
t.Optional[t.MutableMapping[t.Tuple[weakref.ref, str], Template]]Undocumented
def create_cache(size): (source)

Return the cache class for the given size.

Parameters
size:intUndocumented
Returns
t.Optional[t.MutableMapping[t.Tuple[weakref.ref, str], Template]]Undocumented
@lru_cache(maxsize=10)
def get_spontaneous_environment(cls, *args): (source)

Return a new spontaneous environment. A spontaneous environment is used for templates created directly rather than through an existing environment. :param cls: Environment class to create. :param args: Positional arguments passed to environment.

Parameters
*args:t.AnyUndocumented
Returns
_env_boundUndocumented
def load_extensions(environment, extensions): (source)

Load the extensions from the list and bind it to the environment. Returns a dict of instantiated extensions.

Parameters
environment:EnvironmentUndocumented
extensions:t.Sequence[t.Union[str, t.Type[Extension]]]Undocumented
Returns
t.Dict[str, Extension]Undocumented
def _environment_config_check(environment): (source)

Perform a sanity check on the environment.

Parameters
environment:EnvironmentUndocumented
Returns
EnvironmentUndocumented
_env_bound = (source)

Undocumented