December 18, 2012
As I was looking for templating tools to use I came across Mustache. It implements a limited language which lets you insert values or templates. Nested templates inherit context, which is very cool, and some limited conditions and looping are built in. For example, you can render the same template for all the elements in a collection, and you can display a block conditional on the truthy/falsyness of the result of a method call.
Mustache implements pretty much exactly what I was trying for when I rolled my own templating language for this blog. I later gave up on rolling my own and used ERb instead, but if I had known Mustache existed I would have used it. In fact, it seems to be what a lot of people are looking for - it has been implemented in quite a few different programming languages, and there are the odd few convenience tools (e.g. jquery.mustache) that make it easier to use across a wide variety of technologies, particularly if you separate your concerns well. As it is, I might still switch the blog over to it. But I won’t bother until something else breaks.