9 releases
0.2.5 | May 16, 2024 |
---|---|
0.2.4 | May 13, 2024 |
0.2.2 | Apr 26, 2024 |
0.1.2 | Apr 25, 2024 |
#42 in Template engine
26KB
144 lines
texp
is a compact tool designed for rendering templates in a syntax reminiscent of Jinja, powered by Tera. It's useful for generating text output based on predefined templates and variable files.
Learn more about template syntax on the Tera Documentation.
sage: texp [OPTIONS] <path>
Arguments:
<path>
Options:
-v, --values <VALUES> Path to yaml file with values
--set <SET> Set value, e.g "--set foo.a=bar --set foo.b=baz"
-o, --output <OUTPUT> Path to output file
-h, --help Print help
-V, --version Print version
Table of Contents:
Examples
Below is a simple demonstration of how texp
works. Start by creating two files: one for variables and one for the template.
variables.yaml:
foo: bar
doc.template.html:
<p>{{ foo }}</p>
Running texp with these files as inputs:
texp -v variables.yaml doc.template.html
produces the output:
<p>bar</p>
Also you can set output flag, to save result to file:
texp -v variables.yaml -o doc.html doc.template.html
Installation
Prebuilt Binaries
Download the latest releases from the GitHub release page.
Via cargo
cargo install texp
Via homebrew
brew tap fixcik/tap
brew install texp
Custom functions
randomString
Generates random string, with given length:
{{ randomString(length=20) }}
jwtToken
Generate jwt token
{{ jwtToken(claims=claims, secret=secret) }}
Custom filters
base64
{{ "text" | base64 }}
renders:
dGV4dA==
Dependencies
~13–23MB
~328K SLoC