Client side Templating using Underscore.js and JQuery

Recently, I ran into requirement where I was getting JSON response and needed to render it on my Mobile application. I had two Options, Server side processing and Client side Templating. I studied and checked both way ; came to conclusion on using Client side Templating. There are many plugins and libraries available however there is one which stands different, easy to use and faster as compared to others which is “Underscore.js“.

Underscore.js library needs JQuery as prerequisite. You can find complete documentation here, Only remember following three points :

  1. <% %> – to execute some code
  2. <%= %> – to print some value in template
  3. <%- %> – to print some values with HTML escaped

Example Source code:

Continue reading “Client side Templating using Underscore.js and JQuery”