When comparing Underscore Templates vs XSLT in-browser implementation, 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 XSLT in-browser implementation is ranked 31st. 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 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 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 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.