μfmt
μfmt (mufmt) is a minimal and extensible runtime formatting library.
μfmt allows arbitrary types to define a formatting syntax and compiled template format.
μfmt also provides a number of built-in formats, backed by data stored in collection types like HashMap or Vec.
Please read the API docs for more detail.
Examples
Render a template using keys read from a HashMap
use Template;
use HashMap;
// The `Ast` is &str
let template = compile.unwrap;
// The `Manifest` is `HashMap<str, str>`
let mfst = from;
assert_eq!;
Render a template by indexing into a Vec.
use Template;
let s = "Order: {1}".to_owned;
// The `Ast` is usize; also use a String to store the template text
// which unlinks the lifetime
let template = compile.unwrap;
// we can drop the original template string
drop;
// The `Manifest` is `Vec<&str>`
let mut mfst = vec!;
assert_eq!;
// Render again, but with new data
mfst.clear;
mfst.push;
mfst.push;
assert_eq!;
// You can even change the type, as long as the `Ast` is the same
let new_mfst = vec!;
assert_eq!;