About five years ago Etsy added support for Mustache as a template language. Mustache_Engine
was chosen as the renderer, but required a bit of customization for our environment:
- Translation support – Prior to message catalogs, continued support for
<msg />
tags was necessary. Rather than re-implement translation support, the implementation uses a two-part render cycle; the first pass leverages theSmarty
renderer for only translations, and the second pass renders the language-specific Mustache. An implementation ofMustache_Loader
was written for this purpose. - Deterministic runtime compilation – Out of the box templates are compiled on demand. To avoid the performance hit in production, templates are built during deploys for all languages and never compiled at runtime. Where and how compilation cache artifacts are persisted are implemented in subclasses of
Mustache_Engine
.
The primary interface for rendering Mustache templates.