[][src]Function varj::parse

pub fn parse(input: &str, vars: &VarjMap) -> Result<String, Error>

Parse the input for VarjBlocks {{ key }} and replace with value

If no VarjBlocks are present in the input string, it is merely copied.

Whitespace surrounding the key is ignored: {{key}} and {{ key }} are equal.

Errors

Will return an error if the input string contains a key that is not provided.

Examples

Basic usage:

// can use type alias VarjMap or just a HashMap<String, String>
let mut vars = varj::VarjMap::new();

// add variables to VarjMap
let key = String::from("name");
let value = String::from("Christopher");
vars.insert(key, value);

// input to parse
let input = "name: {{name}}";

// test result
let expected = "name: Christopher";
let actual = varj::parse(input, &vars)?;

assert_eq!(expected, actual);