macro_rules! custom_function {
($name:expr, $func:expr) => { ... };
}Expand description
Helper macros for creating custom functions and filters
Create a custom function with less boilerplate
ยงExample
use clnrm_template::{custom_function, register_custom_function};
use tera::Tera;
fn my_function(args: &HashMap<String, Value>) -> Result<Value> {
let name = args.get("name").and_then(|v| v.as_str()).unwrap_or("World");
Ok(Value::String(format!("Hello, {}!", name)))
}
let mut tera = Tera::default();
register_custom_function(&mut tera, "hello", my_function).unwrap();