Skip to content
Myr

app.js

This file

Path

examples/markdown/app.js

36 lines · 792 bytes · JavaScript

Last changed by

Not known.

History of this file

Take it

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

Added simple web-service exampleTj Holowaychukbefore adoptionfda31b7

lines 1–36why, one step back
1
2/**3 * Module dependencies.4 */56var express = require('../../lib/express')7 , md = require('node-markdown').Markdown;89var app = express.createServer();1011// register .md so that markdown may comply12// with the express view system by implementing13// a .compile() method1415app.register('.md', {16 compile: function(str, options){17 var html = md(str);18 return function(locals){19 return html.replace(/\{([^}]+)\}/g, function(_, name){20 return locals[name];21 });22 };23 }24});2526// Optional since express defaults to CWD/views2728app.set('views', __dirname + '/views');29app.set('view engine', 'md');3031app.get('/', function(req, res){32 res.render('index', { layout: false, title: 'Markdown Example' });33});3435app.listen(3000);36console.log('Express app started on port 3000');