Crates.io | tompl |
lib.rs | tompl |
version | 0.0.1 |
source | src |
created_at | 2023-03-24 08:40:23.793076 |
updated_at | 2023-03-24 08:40:23.793076 |
description | cli utility for rendering templates with toml args |
homepage | |
repository | https://github.com/semichkin/tompl |
max_upload_size | |
id | 819121 |
size | 20,919 |
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.
cargo install tompl
tompl render --input ./path/to/config.toml --output ./out/rendered.txt
The TOML file should have the following format:
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:
template = "./template.txt"
[params]
name = "John"
age = 30
And the template.txt
file has the following contents:
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