3 releases (breaking)

Uses old Rust 2015

0.3.0 Dec 25, 2016
0.2.0 Dec 24, 2016
0.1.0 Dec 24, 2016

#65 in #super

Download history 4/week @ 2024-07-30 2/week @ 2024-09-17 15/week @ 2024-09-24

74 downloads per month

MIT license

16KB
354 lines

Edo

Crates.io Version Build Status Dependency Status

A super simple templating library for Rust.

Documentation

Examples

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");

License

This code is distributed under the MIT license

Dependencies

~660KB
~13K SLoC