pub struct EngineBuilder { /* private fields */ }Expand description
Builder for Engine.
Obtained via Engine::builder(). Call EngineBuilder::build to construct
the engine after setting options.
Implementations§
Source§impl EngineBuilder
impl EngineBuilder
Sourcepub fn config(self, config: TemplateConfig) -> Self
pub fn config(self, config: TemplateConfig) -> Self
Sets the template configuration.
If not called, TemplateConfig::default() is used.
Sourcepub fn function<N, F, Rv, Args>(self, name: N, f: F) -> Selfwhere
N: Into<Cow<'static, str>> + Send + 'static,
F: Function<Rv, Args> + Send + Sync + 'static,
Rv: FunctionResult,
Args: for<'a> FunctionArgs<'a>,
pub fn function<N, F, Rv, Args>(self, name: N, f: F) -> Selfwhere
N: Into<Cow<'static, str>> + Send + 'static,
F: Function<Rv, Args> + Send + Sync + 'static,
Rv: FunctionResult,
Args: for<'a> FunctionArgs<'a>,
Registers a custom MiniJinja global function.
name is the name used in templates (e.g. "greet"), f is any value that
implements minijinja::functions::Function.
Sourcepub fn filter<N, F, Rv, Args>(self, name: N, f: F) -> Selfwhere
N: Into<Cow<'static, str>> + Send + 'static,
F: Function<Rv, Args> + Send + Sync + 'static,
Rv: FunctionResult,
Args: for<'a> FunctionArgs<'a>,
pub fn filter<N, F, Rv, Args>(self, name: N, f: F) -> Selfwhere
N: Into<Cow<'static, str>> + Send + 'static,
F: Function<Rv, Args> + Send + Sync + 'static,
Rv: FunctionResult,
Args: for<'a> FunctionArgs<'a>,
Registers a custom MiniJinja filter.
name is the filter name used in templates (e.g. "shout"), f is any value
that implements minijinja::functions::Function.
Sourcepub fn i18n(self, i18n: I18n) -> Self
pub fn i18n(self, i18n: I18n) -> Self
Provide a shared I18n handle so templates can call {{ t("key") }}.
If omitted, the engine does not register the t() function — templates
that reference it will fail to render.
Sourcepub fn build(self) -> Result<Engine>
pub fn build(self) -> Result<Engine>
Builds and returns the Engine.
The static-assets directory at TemplateConfig::static_path is walked
once to compute SHA-256 content hashes used by the static_url()
template function for cache busting. If the directory does not exist, an
empty hash map is used and static_url() falls back to unversioned URLs.
§Errors
Returns Error if any file under the static-assets
directory cannot be read while computing content hashes.