I finally managed to add proper templating, only I didn’t do it with Amrita.
The thing is, if you look for Amrita you’re going to find this site, but what you won’t discover is that Taku Nakajima has also started Amrita2 which looks a lot more polished and does some spiffy things with element attributes.
Only I couldn’t decipher the documentation enough to allow me to do attribute substitution and iteration, so I did a turn and dived into erb instead.
Well, a lot has been written about separating code from presentation, and the abuse of javascript and other embedded script languages, the bleeding of controller logic into view elements etc., which is quite true and to be avoided…but all this also has to do with the use you put your embedded code to and, since we are talking about a statically generated site, applying the MVC terminology is inappropriate.
erb achieves with one template what my primitive templating system needed 9 templates for and with only an if and two each loops as embedded code. Early Amrita2 estimations (before I gave up) gave me between 2 and 3 templates that would be pasted together.
All the code in the erb template is used for placement of elements, so I can say I avoided ‘bleeding’ my logic all over the place.
I also managed to reduce the generator code from 192 to 141 lines (counting comments and pretty printing, no time to write the script that reads ‘true’ code lines), not to mention clean up my object hierarchy.
So now the code has two parts, the Site, which is a representation of the content and the Builder part which is the presentation part.

So after this generous refactoring session the code looks lean enough to allow the rest of the wishlist to be implemented. Which is going to be so much easier now that I have a full suite of unit tests with test data and don’t have to use the production site for development.
But the subject of unit testing is something I can rave about some other time.