When comparing Underscore Templates vs Json2html, the Slant community recommends Underscore Templates for most people. In the question“What are the best JavaScript templating engines?” Underscore Templates is ranked 7th while Json2html is ranked 30th. The most important reason people chose Underscore Templates is:
Due to Underscore's optimized performance and ease-of-use it can be deemed as most fit for use in small sections of your code, where you just want a quick and simple template to render your content.
Ranked in these QuestionsQuestion Ranking
Pros
Pro For micro templating
Due to Underscore's optimized performance and ease-of-use it can be deemed as most fit for use in small sections of your code, where you just want a quick and simple template to render your content.
Pro Pre-compilation
Underscore allows you to compile your template once before data is inserted to it.
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 Not a true templating engine
template
in underscore is simply a function which compiles a piece of template into HTML. It's useful for rendering HTML from JSON and it's not very useful when building complex frontend templates.
Con Templates can be hard to read
HTML structure for template replicated in JSON, can be hard to read.
