October 2016
Intermediate to advanced
452 pages
9h 5m
English
EJS is a JavaScript templating engine that works much like Underscore.js and also uses ERB <% %> style delimiters. Alternatively, it also allows the use of [% %] style tags for delimiters.
Just like Underscore.js, EJS allows arbitrary JavaScript to be parsed when used with the standard <% %> ERB style syntax, and allows the evaluation of expressions using an equals sign = following the opening delimiter tag <%= %>:
<ul>
<% for (var i = 0; i < people.length; i++) { %>
<li><%= firstName %> <%= lastName %></li>
<% } %>
</ul>
This template can be used to iterate over a list of objects from which key names are evaluated as variables with different values:
{ "people": [ { "firstName": "Peebo", "lastName": "Sanderson" }, { "firstName": ...Read now
Unlock full access