Skip to content
Myr

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 file

Take it

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

3.4.7Jonathan Ongbefore adoption34c83d7

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

Merge pull request #2008 from agchou/clean-up-codeJonathan Ongbefore adoption2e830ff

lines 5–8why, one step back
5var express = require('../../');
6var http = require('http');7var GithubView = require('./github-view');8var md = require('marked').parse;

3.4.7Jonathan Ongbefore adoption34c83d7

lines 9–17why, one step back
9
10var 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 back
18 });

3.4.7Jonathan Ongbefore adoption34c83d7

lines 19–22why, one step back
19 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 back
23});

3.4.7Jonathan Ongbefore adoption34c83d7

lines 24–35why, one step back
24
25// 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 back
36});

3.4.7Jonathan Ongbefore adoption34c83d7

lines 37–40why, one step back
37
38app.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 back
41});

3.4.7Jonathan Ongbefore adoption34c83d7

line 42why, one step back
42

Merge tag '3.9.0'Douglas Christopher Wilsonbefore adoptiondb4448d

line 43why, one step back
43/* istanbul ignore next */

3.4.7Jonathan Ongbefore adoption34c83d7

lines 44–47why, one step back
44if (!module.parent) {
45 app.listen(3000);46 console.log('Express started on port 3000');47}