This sample app demonstrates the use of ejs templates.
git clone https://github.com/DWDatITP/sample-templates-ejs.git
cd sample-templates-ejs
npm install
nodemon server.js
- open http://localhost:5000
- 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.