index.js
This file
Path
examples/ejs/index.js
50 lines · 1.2 KiB · JavaScript
Last changed by
Merge tag '3.9.0'Douglas Christopher Wilsonbefore adoptiondb4448d
History of this fileTake it
The walk stopped after 200 commits: lines older than 2e68ddb point at it.
expose connect.middleware using Object.getOwnPropertyDescriptor()Jonathan Ongbefore adoption2e68ddb
lines 1–45why, one step back1/**2 * Module dependencies.3 */45var express = require('../../');67var app = module.exports = express();89// Register ejs as .html. If we did10// not call this, we would need to11// name our views foo.ejs instead12// of foo.html. The __express method13// is simply a function that engines14// use to hook into the Express view15// system by default, so if we want16// to change "foo.ejs" to "foo.html"17// we simply pass _any_ function, in this18// case `ejs.__express`.1920app.engine('.html', require('ejs').__express);2122// Optional since express defaults to CWD/views2324app.set('views', __dirname + '/views');2526// Without this you would need to27// supply the extension to res.render()28// ex: res.render('users.html').29app.set('view engine', 'html');3031// Dummy users32var users = [33 { name: 'tobi', email: 'tobi@learnboost.com' },34 { name: 'loki', email: 'loki@learnboost.com' },35 { name: 'jane', email: 'jane@learnboost.com' }36];3738app.get('/', function(req, res){39 res.render('users', {40 users: users,41 title: "EJS example",42 header: "Some users"43 });44});45Merge tag '3.9.0'Douglas Christopher Wilsonbefore adoptiondb4448d
line 46why, one step back46/* istanbul ignore next */expose connect.middleware using Object.getOwnPropertyDescriptor()Jonathan Ongbefore adoption2e68ddb
lines 47–48why, one step back47if (!module.parent) {48 app.listen(3000);Merge tag '3.9.0'Douglas Christopher Wilsonbefore adoptiondb4448d
line 49why, one step back49 console.log('Express started on port 3000');expose connect.middleware using Object.getOwnPropertyDescriptor()Jonathan Ongbefore adoption2e68ddb
line 50why, one step back50}