| Crates.io | edo |
| lib.rs | edo |
| version | 0.3.0 |
| created_at | 2016-12-24 06:01:40.681859+00 |
| updated_at | 2016-12-25 00:15:32.662245+00 |
| description | A super simple templating library for Rust |
| homepage | https://github.com/giodamelio/edo |
| repository | https://github.com/giodamelio/edo |
| max_upload_size | |
| id | 7754 |
| size | 16,349 |
A super simple templating library for Rust.
You can use a simple static replacement.
use edo::Edo;
let mut template = Edo::new("Hello {name}").unwrap();
template.register_static("name", "World!");
let output = template.render();
assert_eq!(output, "Hello World!");
You can also use a handler function to calculate the value.
use edo::Edo;
let mut template = Edo::new("Hello {name}").unwrap();
template.register_handler("name", |_| Ok("World!".to_string()));
let output = template.render();
assert_eq!(output, "Hello World!");
Your handlers can also take arguments (As a Vec<str>).
use edo::Edo;
let mut template = Edo::new("{say_hello(World)}").unwrap();
template.register_handler("say_hello", |args| Ok(format!("Hello {}", args[0])));
let output = template.render();
assert_eq!(output, "Hello World");
This code is distributed under the MIT license