Skip to content

Instantly share code, notes, and snippets.

@moaoa
Created June 22, 2020 13:32
Show Gist options
  • Save moaoa/d6debcb597be00d3ffd388ffea110a27 to your computer and use it in GitHub Desktop.
Save moaoa/d6debcb597be00d3ffd388ffea110a27 to your computer and use it in GitHub Desktop.
1 . you need to create the views directory
2 . include this line of code : app.set('view engine', 'ejs');
// include partials
<% include ../partials/head %>
// loop over data
<h2>Loop</h2>
<ul>
<% drinks.forEach(function(drink) { %>
<li><%= drink.name %> - <%= drink.drunkness %></li>
<% }); %>
</ul>
// to print variable value
<%= var %>
<% 'Scriptlet' tag, for control-flow, no output
<%_ ‘Whitespace Slurping’ Scriptlet tag, strips all whitespace before it
<%= Outputs the value into the template (HTML escaped)
<%- Outputs the unescaped value into the template
<%# Comment tag, no execution, no output
<%% Outputs a literal '<%'
%> Plain ending tag
-%> Trim-mode ('newline slurp') tag, trims following newline
_%> ‘Whitespace Slurping’ ending tag, removes all whitespace after it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment