When comparing Closure Templates vs XSLT in-browser implementation, the Slant community recommends Closure Templates for most people. In the question“What are the best JavaScript templating engines?” Closure Templates is ranked 19th while XSLT in-browser implementation is ranked 31st. The most important reason people chose Closure Templates is:
The same template written in Closure would work both on Java as well as javascript.
Ranked in these QuestionsQuestion Ranking
Pros
Pro Language independent
The same template written in Closure would work both on Java as well as javascript.
Pro Well Tested and used by Gmail and Google Docs
Closure Templates being a project created by Google, is extensively used in some of the world's most famous and largest web apps which include Gmail and Google Docs. What this means for you is that you'll be using a Template engine that has not only been intensively tested but also that you'll be in good company, with lots of technical support.
Pro Secure
Closure has been designed keeping most security risks in mind. Templates created using Closure are auto-escaped automatically. Hence you won't have to worry about any XSS attacks.
Pro High Performance
Closure templates do not tend to slow down your site's performance or increase your page load time. They're compiled to extremely efficient JS code so that your page renders extremely fast, whether the templating is done on the client end or the server end.
Pro Permits pipelining
I.e. apply one template on top of another.
Pro AOP model
With ability to split feature implementation apart from main codebase, development became quite more manageable. Example: for data of particular type you could define own rendering or render refine rules; pipelining allows incrementally change UI by adding/removing elements depend of parameters, data values, previously rendered content.
Pro Native multithreaded implementation
Only template engine which utilizes multithreading.
Pro Native pre-compilation available
In some browsers(IE) XSLT during load is compiled into DLL. In others pre-loaded template allows to skip recurring parsing .
Pro Accept native data out of JS heap
XML when stored, saved outside of JS heap, capable to work with amount of data 100x larger of JSON.
Pro Native implementation
Supported in all browsers, starting from IE5.
Pro Server side rendering
XSLT is available as in browser as on server side via various libs including highly optimized for CPU.
Cons
Con Hard to find what you need in documentation
Docs are pretty, but hard to find exactly what you need. Although language has nice macros, you're going to hate them when they fail and you search for info for half an hour.
Con Strange errors from compiler
You won't get used to them even after a while.
Con Not widely used outside of Google
Closure Templates are mostly used in projects developed by Google and not in projects by third-parties. As such, it's unlikely for further versions to be released or for changes to be merged.
Con Lack of SDLC for in-browser development
It will take time to collect complete gentleman set: debugging, modular development, documenting, unit tests, etc. Please share if know the book on subject.
Con Verbose syntax
Takes time to get used to.
Con AOP model
Is complex to comprehend, justifiable on complex projects.