register_functions

Macro register_functions 

Source
macro_rules! register_functions {
    ($tera:expr, { $($name:expr => $func:expr),* $(,)? }) => { ... };
}
Expand description

Register multiple functions at once

ยงExample

use clnrm_template::{register_functions, custom_function};
use tera::Tera;
use std::collections::HashMap;
use serde_json::Value;

fn func1(args: &HashMap<String, Value>) -> Result<Value> { /* ... */ }
fn func2(args: &HashMap<String, Value>) -> Result<Value> { /* ... */ }

let mut tera = Tera::default();
register_functions!(&mut tera, {
    "my_func1" => func1,
    "my_func2" => func2,
}).unwrap();