A string interpolation utility to replace Mustache like placeholders with stored variables.
{{ key }}
with value
{{key}}
and {{ key }}
are equal.Interact with this utility via VarjMap
.
Basic usage:
```rust let mut vars = varj::VarjMap::new(); vars.insert("key", "value");
let expected = "value"; let actual = vars.parse("{{ key }}")?;
assert_eq!(expected, actual); ```
With a json string:
```rust let mut variables = varj::VarjMap::new(); variables.insert("name", "Christopher"); variables.insert("age", "30");
let json = r#"{ "name" = "{{ name }}", "age" = {{ age }} }"#;
let expected = r#"{ "name" = "Christopher", "age" = 30 }"#;
let actual = variables.parse(json)?;
assert_eq!(expected, actual); ```
Varj is distributed under the terms of both the MIT license and the Apache License (Version 2.0).
See LICENSE-APACHE and LICENSE-MIT for details.