Home
NOTE: I'm in the middle of upgrading the site. Most things are in place, but some things are missing and/or broken. This includes alt text for images. Please bear with me while I get 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)

```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
~ fin ~