This is a CLI utility written in Rust that allows you to render templates using args specified in a TOML file. The tool uses the clap and handlebars libraries for command line argument parsing and template rendering respectively.
To use this tool, you need to have Rust installed on your system.
You can then install the tool using cargo
, Rust's package manager.
bash
cargo install tompl
bash
tompl render --input ./path/to/config.toml --output ./out/rendered.txt
The TOML file should have the following format:
```toml template = "./path/to/template.txt"
[params] param1 = "value1" nparam2 = "value2" user = "{{env.USER}}" ```
template
: The path to the template file that you want to render.params
: A table containing the arguments that you want to pass to the template.You can use the env
parameter in the params
table to access environment variables.
Assuming that the config.toml
file has the following contents:
```toml template = "./template.txt"
[params] name = "John" age = 30 ```
And the template.txt
file has the following contents:
txt
Hello, {{name}}!
You are {{age}} years old.
Environment variables:
{{#each env}}
- {{@key}}: {{this}}
{{/each}}
The above command will render the template using the arguments specified in the TOML file and write the output to the output.txt
file