diff --git a/node.md b/node.md index d9d0bfd..8799cfc 100644 --- a/node.md +++ b/node.md @@ -103,8 +103,50 @@ controller.get('/', function(req, res){ //route for finding all routes by a the module.exports = controller; ``` - ## Views + +Let's separate the views from the controller. Install express with `npm install ejs --save` + +Create a directory called 'views' and create an appropriately named file with the extension .ejs. Now we can reference it. Express will assume the file path starts with the 'views' directory you created. + +```javascript +var controller = require('express').Router(); //require express and create a router (controller) +controller.get('/', function(req, res){ //route for finding all routes by a the session user + res.render('viewFile.ejs'); +}); +module.exports = controller; +``` + +EJS files are just html, but you can use javascript to dynamically create HTML: + +```html +