For simple templating I use my own version[1] of pp[2] preprocessor. The idea behind it is ridiculously simple: everything between ^#!$ markers is shell script. Output of the script is pasted verbatim in the document.
[1]: https://github.com/TeddyDD/pp.awk [2]: https://www.mkws.sh/pp.html