We’re about to start a new website with Enonic XP (hooray), and we’re at a crossroads when it comes to choosing a templating library.
I’ve always been a huge fan of Mustache - so I was thinking of suggesting that for this project. However, there is just about no documentation about how to use it with Enonic. When is this planned?
Would you even suggest to use anything but Thymeleaf for the current version?
As far as I know Mustache for XP doesn’t support usage of “portal” functions directly in the view. You must “parse” that data in your controller before sending it as variables to your view. Perhaps not a big deal breaker (unless I’m missing something here).
Thymeleaf is coded as HTML - specifically using html5 data attributes, so it is very good at producing html, less good at xml - and not in particular useful for producing JSON. The fact that any valid HTML5 page is also a valid thymeleaf template (and visa versa) speaks for itself - it is probalby the best server side HTML5 templating engine available.
XSLT is coded in xml, using xml concepts such as namespaces etc etc. It also requires XML as input - and it is best at producing an XML as output too… (xhtml is xml too you know). No wonder Enonic CMS was good at producing high quality HTML all the way as it used xslt for everything. XSLT is a bit hard to learn, and not very suited for producing non-markup results
Mustache is relying on JSON objects passed in, and is quite flexible at what it outputs - so given that Thymeleaf and XSLT both are are more specialized for their respective formats, Mustache is the obvious choice for JSON (and other output formats).
You can naturally also add your own templating language as a library to your project too, say freemarker if you like that. However, there might be some work getting the portal functions working - but I guess that’s optional?