Skip to content
Myr

app.js

This file

Path

examples/markdown/app.js

44 lines · 944 bytes · JavaScript

Last changed by

Updated markdown example with acceptance test.Robert Sköldbefore adoption4dbaaa2

History of this file

Take it

The walk stopped after 200 commits: lines older than f98c112 point at it.

Added app.render() local precedence testTj Holowaychukbefore adoptionf98c112

lines 1–5why, one step back
1
2/**3 * Module dependencies.4 */5

Updated markdown example with acceptance test.Robert Sköldbefore adoption4dbaaa2

lines 6–7why, one step back
6var express = require('../../')
7 , fs = require('fs')

Added app.render() local precedence testTj Holowaychukbefore adoptionf98c112

lines 8–9why, one step back
8 , md = require('node-markdown').Markdown;
9

Updated markdown example with acceptance test.Robert Sköldbefore adoption4dbaaa2

line 10why, one step back
10var app = module.exports = express();

Added app.render() local precedence testTj Holowaychukbefore adoptionf98c112

line 11why, one step back
11

Updated markdown example with acceptance test.Robert Sköldbefore adoption4dbaaa2

line 12why, one step back
12// register .md as an engine in express view system

Added app.render() local precedence testTj Holowaychukbefore adoptionf98c112

line 13why, one step back
13

Updated markdown example with acceptance test.Robert Sköldbefore adoption4dbaaa2

lines 14–27why, one step back
14app.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(e){24 fn(e)25 }26 })27})

Added app.render() local precedence testTj Holowaychukbefore adoptionf98c112

lines 28–33why, one step back
28
29// Optional since express defaults to CWD/views30app.set('views', __dirname + '/views');31app.set('view engine', 'md');3233app.get('/', function(req, res){

Updated markdown example with acceptance test.Robert Sköldbefore adoption4dbaaa2

lines 34–35why, one step back
34 res.render('index', { title: 'Markdown Example' });
35})

Added app.render() local precedence testTj Holowaychukbefore adoptionf98c112

line 36why, one step back
36

Updated markdown example with acceptance test.Robert Sköldbefore adoption4dbaaa2

lines 37–44why, one step back
37app.get('/fail', function(req, res){
38 res.render('missing', { title: 'Markdown Example' });39})4041if (!module.parent) {42 app.listen(3000);43 console.log('Express started on port 3000');44}