├── .gitignore ├── README.md ├── package.json ├── server.js └── views ├── pages ├── about.ejs └── index.ejs └── partials ├── footer.ejs ├── head.ejs └── header.ejs /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | 5 | # Runtime data 6 | pids 7 | *.pid 8 | *.seed 9 | 10 | # Directory for instrumented libs generated by jscoverage/JSCover 11 | lib-cov 12 | 13 | # Coverage directory used by tools like istanbul 14 | coverage 15 | 16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 17 | .grunt 18 | 19 | # Compiled binary addons (http://nodejs.org/api/addons.html) 20 | build/Release 21 | 22 | # Dependency directory 23 | # Deployed apps should consider commenting this line out: 24 | # see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git 25 | node_modules 26 | 27 | .DS_Store -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | node-ejs 2 | ======== 3 | 4 | Using EJS to template a Node application. 5 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "node-ejs", 3 | "main": "server.js", 4 | "dependencies": { 5 | "ejs": "^1.0.0", 6 | "express": "^4.6.1", 7 | "express-ejs-layouts": "^1.1.0" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /server.js: -------------------------------------------------------------------------------- 1 | // load the things we need 2 | var express = require('express'); 3 | var app = express(); 4 | 5 | // set the view engine to ejs 6 | app.set('view engine', 'ejs'); 7 | 8 | // use res.render to load up an ejs view file 9 | 10 | // index page 11 | app.get('/', function(req, res) { 12 | res.render('pages/index'); 13 | }); 14 | 15 | // about page 16 | app.get('/about', function(req, res) { 17 | res.render('pages/about'); 18 | }); 19 | 20 | app.listen(8080); 21 | console.log('8080 is the magic port'); -------------------------------------------------------------------------------- /views/pages/about.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | <% include ../partials/head %> 5 | 6 | 7 | 8 |
9 | <% include ../partials/header %> 10 |
11 | 12 |
13 |
14 |
15 | 16 |
17 |

This is great

18 |

Welcome to templating using EJS

19 |
20 | 21 |
22 |
23 | 24 |
25 |

Look I'm A Sidebar!

26 |
27 | 28 |
29 |
30 |
31 | 32 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /views/pages/index.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | <% include ../partials/head %> 5 | 6 | 7 | 8 |
9 | <% include ../partials/header %> 10 |
11 | 12 |
13 |
14 |

This is great

15 |

Welcome to templating using EJS

16 |
17 |
18 | 19 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /views/partials/footer.ejs: -------------------------------------------------------------------------------- 1 |

© Copyright 2014 The Awesome People

-------------------------------------------------------------------------------- /views/partials/head.ejs: -------------------------------------------------------------------------------- 1 | 2 | Super Awesome 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /views/partials/header.ejs: -------------------------------------------------------------------------------- 1 | --------------------------------------------------------------------------------