After resuming work on my experimental class, I’ve noticed some things:
— My past self made some dubious organizational and implementation decisions.
— Although xtemplate provides for hierarchical design, it isn’t as robust as, say, CSS.
— Importantly: xtemplate ends up being used for two distinct purposes:
1. Document-level objects, e.g. titles, sections, &c. (xtemplate’s intended use)
2. Typesetting-level objects, e.g. complex layouts, xgalley (an unintended use)
I think that the takeaway from this observation is that building a library of composable, parameterized “objects” works well at both the document content and the typesetting layers. That’s not much of a revelation, but it was interesting to see the parallels.
Although the ideas involved are similar, I suspect that the interfaces should not be the same at the document content and typesetting levels. I may try playing with some ideas to see what works better for each layer.
* * *
One thing that I dislike about xtemplate is that the typesetting and programming logic are combined in a single “implementation” block. It should be possible to specify separately the typesetting and the other code (e.g. integer changes, file operations, PDF tagging and links, &c.).
Of course, for this separated approach to work, careful consideration has to be paid to when/where code is executed. For example, numbering could be typeset with an off-by-one error, if a counter increment happens at the wrong time.
A simple solution would be that, for document-level objects, there are two code insertion points: before and after typesetting. Code that needs to be executed during typesetting would be part of the implementation of the high-level typesetting language and be independent of document-level code.
I think that this approach would work for most cases but I don’t know if that’s true. There’s also the question of how composition would work, with this approach. I’d need to consider some examples of complex composition.
* * *
I like that xtemplate allows me to structure things and compose pieces to make something bigger. That organizational aspect definitely helps when building things.
* * *
Make of these thought what you will; I hope that they’re of some use.