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.
I wrote something similar in my static collection of sysadmin tools - https://github.com/skx/sysbox - In my simple pre-processor I only allow two special things:
#include "file/goes/here"
#execute ls -l | wc -l
Though there is a more complex version included, which supports all the syntax of the golang text/template library which is more powerful.
[1]: https://github.com/TeddyDD/pp.awk [2]: https://www.mkws.sh/pp.html