Home
Head's Up: I'm in the middle of upgrading my site. Most things are in place, but there are something missing and/or broken including image alt text. Please bear with me while I'm getting things fixed.

Call A Rust Function With Attributes From A minijinja Template

This calls from a top level function (i.e. it's not on the object that was sent into the template)

rust
```cargo
[dependencies]
minijinja = "1.0.8"
```

use minijinja::{context, Environment};

fn main() {
    let mut env = Environment::new();
    env.add_template("ping_test", "{{ ping('alfa') }}").unwrap();
    env.add_function("ping", ping);
    let tmpl = env.get_template("ping_test").unwrap();
    println!("{}", tmpl.render(context!()).unwrap());
}

fn ping(source: &str) -> String {
    format!("Got: {}", source)
}
results start