Tell me how to use underscore.js as a template engine?

Answer

Everything you need to know about underscore template is here. Only 3 things to keep in mind:

<% %> - to execute some code
<%= %> - to print some value in template
<%- %> - to print some values with HTML escaped

That's all about it.

Simple example:

var foo = "blahblah";
var tpl = _.template("<h1>Heading for: <= fooo %></h1>");

this would be rendered in string <h1>Heading for: blahblah</h1> 

All node.js Questions

Ask your interview questions on node-js

Write Your comment or Questions if you want the answers on node-js from node-js Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---