When comparing Closure Templates vs Json2html, 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 Json2html is ranked 30th. 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 Embedded jQuery Events
Allows for jQuery events to be embedded within the template when used on the client.
Pro No special template syntax to learn
Templates are JSON objects that can include javascript functions to render any complex logic.
Pro Portable to server and client
Templates are stored as JSON rather than HTML, easily ported to both client and server.
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 Templates can be hard to read
HTML structure for template replicated in JSON, can be hard to read.