This year, one of my nice discoveries was gomplate, a fast template renderer supporting many data sources and hundreds of functions.
And finally, gomplate v4 was released in June 2024. It has many excellent new features and additions (v3 was released in 2018!).
I will not really cover much here as it has extensive documentation. The most basic example could be:
echo 'Hello, {{ .Env.USER }}' | gomplate Hello, ahmed
But I totally like the idea of the separation between data input (data source) and rendering, so I can generate the data with any tool and then just leave the rendering to gomplate like:
Template file:
{{- $release := ds "release" -}} {{- with $release -}} Version: .version {{- end -}}
Rendering command:
RELEASE_DATA_JSON='{"version": "1.0.0"}' gomplate \ --config .gomplate.yaml \ --file RELEASE.md.tpl \ --datasource release=env:///RELEASE_DATA_JSON?type=application/json
Of course, that's still super basic, but the idea here is that I could generate the data of env var RELEASE_DATA_JSON or even generate a JSON file and read it in gomplate.
What's better? It's already available in asdf! Just add it directly or declaratively via asdf plugin manager.
asdf plugin-add gomplate
If you want a decent tool for templating, then gomplate is your tool to go.
Enjoy :-)