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 :
- <% %> – to execute some code
- <%= %> – to print some value in template
- <%- %> – to print some values with HTML escaped
Example Source code: