[][src]Function germinate::parse

pub async fn parse<T: AsRef<str>>(input: T) -> Result<HashMap<String, String>>

Parses the input string for template strings and returns a HashMap of template strings and their associated values

Examples

#[tokio::main]
async fn main() {
    std::env::set_var("MY_VAR", "success");
    let mut s = String::from("The value of MY_VAR is %env:MY_VAR%");
    let replacements = germinate::parse(&s).await.unwrap();
    for (find, replace) in replacements {
        s = s.replace(&find, &replace);
    };

    assert_eq!("The value of MY_VAR is success", s);
}