index.js
This file
Path
examples/ejs/index.js
51 lines · 1.2 KiB · JavaScript
Last changed by
tests: exclude untestable lines in examples from coverageDouglas Christopher Wilsonbefore adoptionc18c2a8
History of this fileTake it
The walk stopped after 200 commits: lines older than a10f695 point at it.
pin jade dev dep so tests do not breakTJ Holowaychukbefore adoptiona10f695
lines 1–46why, 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// system by default, so if we want17// to change "foo.ejs" to "foo.html"18// we simply pass _any_ function, in this19// case `ejs.__express`.2021app.engine('.html', require('ejs').__express);2223// Optional since express defaults to CWD/views2425app.set('views', __dirname + '/views');2627// Without this you would need to28// supply the extension to res.render()29// ex: res.render('users.html').30app.set('view engine', 'html');3132// Dummy users33var users = [34 { name: 'tobi', email: 'tobi@learnboost.com' },35 { name: 'loki', email: 'loki@learnboost.com' },36 { name: 'jane', email: 'jane@learnboost.com' }37];3839app.get('/', function(req, res){40 res.render('users', {41 users: users,42 title: "EJS example",43 header: "Some users"44 });45});46tests: exclude untestable lines in examples from coverageDouglas Christopher Wilsonbefore adoptionc18c2a8
line 47why, one step back47/* istanbul ignore next */pin jade dev dep so tests do not breakTJ Holowaychukbefore adoptiona10f695
lines 48–49why, one step back48if (!module.parent) {49 app.listen(3000);tests: exclude untestable lines in examples from coverageDouglas Christopher Wilsonbefore adoptionc18c2a8
line 50why, one step back50 console.log('Express started on port 3000');pin jade dev dep so tests do not breakTJ Holowaychukbefore adoptiona10f695
line 51why, one step back51}