[][src]Crate markings

use markings::{Args, Template};
struct Foo<'a> {
    thing: &'a str,
}
impl<'a> std::fmt::Display for Foo<'a> {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "{}", self.thing)
    }
}

let test = Foo{thing: "test"};
let test = Args::new().with("thing", &test).with("end", &"!").build();

let demo = Foo{thing: "demo_"};
let demo = Args::new().with("thing", &demo).with("end", &42).build();

let input = "this is a ${thing}${end}";
let template = Template::parse(&input).unwrap();

let output = template.clone().apply(&test).unwrap();
assert_eq!(output, "this is a test!");

let output = template.clone().apply(&demo).unwrap();
assert_eq!(output, "this is a demo_42");

Structs

Args

This allows you to be args for the Template::apply method

Template

Template allows for string replacement by name

Enums

Error

Errors returned by the Template parser/applier