index.js
This file
Path
examples/ejs/index.js
43 lines · 971 bytes · JavaScript
Last changed by
ejs testTj Holowaychukbefore adoption43c09b2
History of this fileTake it
ejs testsTj Holowaychukbefore adoption3b6e96e
lines 1–30why, one step back12/**3 * Module dependencies.4 */56var express = require('../../');78var app = module.exports = express();910// Register ejs as .html. If we did11// not call this, we would need to12// name our views foo.ejs instead13// of foo.html. The __express method14// is simply a function that engines15// use to hook into the Express view16// system1718app.engine('.html', require('ejs').__express);1920// Optional since express defaults to CWD/views2122app.set('views', __dirname + '/views');2324// Without this you would need to25// supply the extension to res.render()26// ex: res.render('users.html').27app.set('view engine', 'html');2829// Dummy users30var users = [ejs testTj Holowaychukbefore adoption43c09b2
lines 31–33why, one step back31 { name: 'tobi', email: 'tobi@learnboost.com' }32 , { name: 'loki', email: 'loki@learnboost.com' }33 , { name: 'jane', email: 'jane@learnboost.com' }ejs testsTj Holowaychukbefore adoption3b6e96e
lines 34–43why, one step back34];3536app.get('/', function(req, res){37 res.render('users', { users: users });38});3940if (!module.parent) {41 app.listen(3000);42 console.log('Express app started on port 3000');43}