Skip to content

Latest commit

 

History

History
20 lines (15 loc) · 963 Bytes

README.md

File metadata and controls

20 lines (15 loc) · 963 Bytes

Sample Templating

This sample app demonstrates the use of ejs templates.

Installation

  • git clone https://github.com/DWDatITP/sample-templates-ejs.git
  • cd sample-templates-ejs
  • npm install
  • nodemon server.js
  • open http://localhost:5000

Adding EJS to your existing app

  • This will download the ejs module and update your package.json to list it (important for when you deploy to Heroku):
  • npm install --save ejs
  • Then, update your server.js file to set the app's view engine to ejs:
  • app.set('view engine', 'ejs'); # Here it is in the server.js code.
  • Next, create a folder called "views"
  • Now, in your app's handler you can call res.render('viewName'). The app will look up a file called 'viewName.ejs' in your views folder and render it.