index.js
This file
Path
examples/markdown/index.js
46 lines · 973 bytes · 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–41why, one step back12/**3 * Module dependencies.4 */56var express = require('../..')7 , fs = require('fs')8 , md = require('marked').parse;910var app = module.exports = express();1112// register .md as an engine in express view system1314app.engine('md', function(path, options, fn){15 fs.readFile(path, 'utf8', function(err, str){16 if (err) return fn(err);17 try {18 var html = md(str);19 html = html.replace(/\{([^}]+)\}/g, function(_, name){20 return options[name] || '';21 })22 fn(null, html);23 } catch(err) {24 fn(err);25 }26 });27})2829app.set('views', __dirname + '/views');3031// make it the default so we dont need .md32app.set('view engine', 'md');3334app.get('/', function(req, res){35 res.render('index', { title: 'Markdown Example' });36})3738app.get('/fail', function(req, res){39 res.render('missing', { title: 'Markdown Example' });40})41tests: exclude untestable lines in examples from coverageDouglas Christopher Wilsonbefore adoptionc18c2a8
line 42why, one step back42/* istanbul ignore next */pin jade dev dep so tests do not breakTJ Holowaychukbefore adoptiona10f695
lines 43–46why, one step back43if (!module.parent) {44 app.listen(3000);45 console.log('Express started on port 3000');46}