Struct minijinja::Environment[][src]

pub struct Environment<'source> { /* fields omitted */ }
Expand description

An abstraction that holds the engine configuration.

This object holds the central configuration state for templates and their configuration. Instances of this type may be modified if no template were loaded so far. Modifications on environments after the first template was loaded will lead to surprising effects and undefined behavior. For instance overriding the auto escape callback will no longer have effects to an already loaded template.

Implementations

Creates a new environment with sensible defaults.

This environment does not yet contain any templates but it will have all the default filters loaded. If you do not want any default configuration you can use the alternative empty method.

Creates a completely empty environment.

This environment has no filters, no templates and no default logic for auto escaping configured.

Sets a new function to select the default auto escaping.

This function is invoked when templates are added to the environment to determine the default auto escaping behavior. The function is invoked with the name of the template and can make an initial auto escaping decision based on that. The default implementation is to turn on escaping for templates ending with .html, .htm and .xml.

Loads a template from a string.

The name parameter defines the name of the template which identifies it. To look up a loaded template use the get_template method.

Removes a template by name.

Fetches a template by name.

This requires that the template has been loaded with add_template beforehand. If the template was not loaded None is returned.

Compiles an expression.

This lets one compile an expression in the template language and receive the output. This lets one use the expressions of the language be used as a minimal scripting language.

Adds a new filter function.

For details about filters have a look at filters.

Removes a filter by name.

Adds a new test function.

For details about tests have a look at tests.

Removes a test by name.

Trait Implementations

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.