Learning Objectives |
---|
Define EJS and outline use cases |
Implement EJS into a node.js project |
Integration with underscore templating |
EJS partials |
EJS stands for Embedded Javascript.
EJS cleans the HTML out of your JavaScript with client-side templates. After EJS gets its rubber gloves on dirty code, you'll feel organized and uncluttered.
###EJS implementation with node
####Features
- Control flow: (
<% ... %>
) - Escaped output: (
<%= ... %>
) - Client-side support
- Static caching of intermediate JS
- Compatible with Express views
####Tags
<%
Scriptlet tag, for control-flow, no output<%=
Outputs the value into the template (HTML escaped)<%-
Outputs the unescaped value into the template (embeddable as a string)%>
Plain ending tag
#####Example
<% if (puppy) { %>
<h2><%= puppy.name %></h2>
<% } %>
####Resources:
=======