Of course, if you operate within a language ecosystem, you can probably find a nice templating system there. Python, for instance, has Jinja2. Or, if your needs are simple, you can use something more basic, like sed(1).
Of course, if you operate within a language ecosystem, you can probably find a nice templating system there. Python, for instance, has Jinja2. Or, if your needs are simple, you can use something more basic, like sed(1).
Not really crazy about Jinja2 either, but at this point it seems like it has a lot more mindshare and maintenance.
You have loops and conditionals, and functions that take parameters to modularize it (e.g. a function for each table row).
Sequential composition "concatenates" stdout. At the end you redirect it all like this, which is inconvenient in other languages:
top-level-function > out.html
----For example, I generate this page with shell:
http://www.oilshell.org/releases.html
And it's separated into 3-4 functions here:
https://github.com/oilshell/oil/blob/master/devtools/release...
----
Shell falls down when you have to generate complex logic as with tables [1], but m4 also falls down there.
I actually experimented with many different methods in order to help me design the Oil language.
This is generated with awk, and it has some advantages over shell:
https://www.oilshell.org/release/0.8.pre3/test/spec.wwz/osh....
These two are generated with Python:
https://www.oilshell.org/release/0.8.pre3/test/spec.wwz/alia...
https://www.oilshell.org/release/0.8.pre3/test/wild.wwz/
So I hope Oil will do better than shell, awk, and Python.
-----
Shell needs to be better for escaping. Template languages like Jinja do better there. I put m4 in the "70's-style macro processing bucket" which is generally sloppy about escaping.
I use Python for escaping here, but I do it with O(1) processes and not one process for every tiny fragment that needs to be escaped!
Git Log in HTML: A Harder Problem and A Safe Solution http://www.oilshell.org/blog/2017/09/29.html