Simplest possible web templating?
[See old version of this post to see what is being described.]
So, I started off trying to have this blog using simple plain hand-written HTML.
However, I soon start getting annoyed how much repeated boilerplate I had to
write, such as in the <head
and in linking together the articles from the
main index page. So in an effort to make things more DRY I considered what
simple templating systems I could used.
A long time ago, back before the web existed I used the M4 macro language. It has the advantage of being installed on my home Linux machine by default, so no extra dependencies are required. Let’s see if we can use it as an HTML templating language.
You can see an example of a template using M4 in the source code of this blog. Note that there is just one simple line of boilerplate at the top and some closing parenthesis at the bottom, but otherwise the template is straightforward HTML.
ARTI{}CLE( 2, {
...HTML goes here...
})
The templates uses two M4 files: