index.js
This file
Path
examples/view-constructor/index.js
47 lines · 1.2 KiB · JavaScript
Last changed by
Merge tag '3.9.0'Douglas Christopher Wilsonbefore adoptiondb4448d
History of this fileTake it
The walk stopped after 200 commits: lines older than a02dd20 point at it.
update send to 0.2.0Roman Shtylmanbefore adoptiona02dd20
lines 1–4why, one step back1/**2 * Module dependencies.3 */4Merge pull request #2008 from agchou/clean-up-codeJonathan Ongbefore adoption2e830ff
lines 5–8why, one step back5var express = require('../../');6var http = require('http');7var GithubView = require('./github-view');8var md = require('marked').parse;update send to 0.2.0Roman Shtylmanbefore adoptiona02dd20
lines 9–17why, one step back910var app = module.exports = express();1112// register .md as an engine in express view system13app.engine('md', function(str, options, fn){14 try {15 var html = md(str);16 html = html.replace(/\{([^}]+)\}/g, function(_, name){17 return options[name] || '';Merge pull request #2008 from agchou/clean-up-codeJonathan Ongbefore adoption2e830ff
line 18why, one step back18 });update send to 0.2.0Roman Shtylmanbefore adoptiona02dd20
lines 19–22why, one step back19 fn(null, html);20 } catch(err) {21 fn(err);22 }Merge pull request #2008 from agchou/clean-up-codeJonathan Ongbefore adoption2e830ff
line 23why, one step back23});update send to 0.2.0Roman Shtylmanbefore adoptiona02dd20
lines 24–35why, one step back2425// pointing to a particular github repo to load files from it26app.set('views', 'visionmedia/express');2728// register a new view constructor29app.set('view', GithubView);3031app.get('/', function(req, res){32 // rendering a view relative to the repo.33 // app.locals, res.locals, and locals passed34 // work like they normally would35 res.render('examples/markdown/views/index.md', { title: 'Example' });Merge pull request #2008 from agchou/clean-up-codeJonathan Ongbefore adoption2e830ff
line 36why, one step back36});update send to 0.2.0Roman Shtylmanbefore adoptiona02dd20
lines 37–40why, one step back3738app.get('/Readme.md', function(req, res){39 // rendering a view from https://github.com/visionmedia/express/blob/master/Readme.md40 res.render('Readme.md');Merge pull request #2008 from agchou/clean-up-codeJonathan Ongbefore adoption2e830ff
line 41why, one step back41});update send to 0.2.0Roman Shtylmanbefore adoptiona02dd20
line 42why, one step back42Merge tag '3.9.0'Douglas Christopher Wilsonbefore adoptiondb4448d
line 43why, one step back43/* istanbul ignore next */update send to 0.2.0Roman Shtylmanbefore adoptiona02dd20
lines 44–47why, one step back44if (!module.parent) {45 app.listen(3000);46 console.log('Express started on port 3000');47}