Skip to main content

template_function

Attribute Macro template_function 

Source
#[template_function]
Expand description

Registers a function as a named MiniJinja global function.

ยงSyntax

#[template_function]                    // uses the Rust function name
#[template_function(name = "fn_name")] // explicit template name

The function is submitted via inventory and registered into the MiniJinja environment when the TemplateEngine service starts. The inventory::submit! call is guarded by #[cfg(feature = "templates")] in the generated code, so the function definition is always compiled but the registration only takes effect when that feature is enabled on modo.

Requires the templates feature on modo.