A super simple templating library for Rust.
You can use a simple static replacement.
```rust use edo::Edo;
let mut template = Edo::new("Hello {name}").unwrap(); template.registerstatic("name", "World!"); let output = template.render(); asserteq!(output, "Hello World!"); ```
You can also use a handler function to calculate the value.
```rust use edo::Edo;
let mut template = Edo::new("Hello {name}").unwrap(); template.registerhandler("name", || String::from("World!")); let output = template.render(); assert_eq!(output, "Hello World!"); ```
Your handlers can also take arguments (As a Vec<str>
).
```rust use edo::Edo;
let mut template = Edo::new("{sayhello(World)}").unwrap(); template.registerhandler("sayhello", |args| format!("Hello {}", args[0])); let output = template.render(); asserteq!(output, "Hello World"); ```
This code is distributed under the MIT license