16 12 / 2011

Scalate is good but not usable

Scalate is an awesome template engine and i really mean that. Its written in Scala and just fabulous in the way that it supports multiple template languages like HAML(Scaml),Jade and Mustache over a common interface.

Its simple enough to understand and is really easy to write HTML templates using Jade/Scaml without using an IDE. The documentation is decent enough to convince you to use it on your project. Some of the Scala web frameworks like Scalatra use it as the default TE.

But if you are going to use it on a Java web project, be warned. You will end up writing Scala code to support simple operations like iterating a collection. I like the idea that the template gets translated to Scala code but to write Scala foreach or for loops for iterating collections every time is ridiculous. Writing templates should be easy and common tasks should already be provided.

Sure, Scalate lets you call Scala functions and it looks like custom tags in JSP, but the fact that YOU have to write that function makes it look less sexier. I don’t like JSP, i live with it because it has JSTL. Scalate should come up standard set of functions for mundane tasks.

If you are using Spring MVC / Struts 2, both provide tag libraries for JSP. Using Scalate, you have to create your own set of functions to mirror the tag-lib functionality, which is certainly not what you want to do.

Thinking about Scalate for Java web projects, my advice is stay away.