Class 11 Reading EJS - Ginsusamurai/seattle-301d58 GitHub Wiki
- libs
express,cors,body-parser,ejs -
pathmodule is core to node *let's you concat the CWD withviews -
app.set('view engine', 'ejs');create view engine - views folder has
<% index.ejswhich is auto-created- this can find the file automatically
-
response.render('filename', {foo: 'bar'});- let's you pass object vals directly in to a file
-
<%= foo %>is the ejs template tag (like {{}} in angular or handlebars)
- can also take an array of objects
people: [ {name: 'dave'}]-
<% for(var person of people){ %> <% if (person.name === 'dave') { %> <li>This is <%= person.name %></li> <% } else { %> <li> this is not dave, it's <%= person.name %></li> <% } %> <% } %> <% } %>
-