Template with support for optional variables and such.

Introduction

This is a simple template tool that works with variable names and HashMap of String. The Template can be parsed from str and then you can render it using the variables in HashMap and any shell commands running through Exec.

Features

Limitations

Example

let templ = parse_template("hello {nickname?name}. You're $(printf \"%.1f\" {weight})kg").unwrap(); let mut vars: HashMap<String, String> = HashMap::new(); vars.insert("name".into(), "John".into()); vars.insert("weight".into(), "132.3423".into()); let rendered = templ .render(&RenderOptions { wd: PathBuf::from("."), variables: vars, }) .unwrap(); assert_eq!(rendered, "hello John. You're 132.3kg");