Funcy Crates.io Status Documentation

Funcy is a simple function based template engine.

Examples

Echo

```rust struct Echo(); impl funcy::PlaceholderFunction for Echo { fn placeholderfnhandler<'a>(&mut self, name: &'a str, arg: &'a str) -> Result { Ok(arg.tostring()) } }

let mut tr = funcy::TemplateRenderer::withtemplate(", World!"); tr.setplaceholderfn("echo", Box::new(Echo())); asserteq!(tr.render().unwrap(), "Hello, World!"); ```

Counter

```rust struct Counter(usize); impl funcy::PlaceholderFunction for Counter { fn placeholderfnhandler<'a>(&mut self, name: &'a str, _arg: &'a str) -> Result { self.0 += 1; Ok(self.0.tostring()) } }

let mut tr = funcy::TemplateRenderer::withtemplate(" ") let counter = Counter(0); tr.setplaceholderfn("counter", Box::new(counter)); asserteq!(tr.render().unwrap(), "1 2 3"); ```

License

Funcy is distributed under the Apache-2.0 license. See the LICENSE file.