Skip to content
Myr

app.engine.js

This file

Path

test/app.engine.js

81 lines · 2.1 KiB · JavaScript

Last changed by

Merge tag '4.15.4'Douglas Christopher Wilsonbefore adoptionc319fe2

History of this file

Take it

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

deps: serve-static@~1.3.2Douglas Christopher Wilsonbefore adoptiond29cf4d

lines 1–3why, one step back
1
2var express = require('../')3 , fs = require('fs');

Merge tag '4.15.2'Douglas Christopher Wilsonbefore adoptione5dbb0c

line 4why, one step back
4var path = require('path')

deps: serve-static@~1.3.2Douglas Christopher Wilsonbefore adoptiond29cf4d

lines 5–18why, one step back
5
6function render(path, options, fn) {7 fs.readFile(path, 'utf8', function(err, str){8 if (err) return fn(err);9 str = str.replace('{{user.name}}', options.user.name);10 fn(null, str);11 });12}1314describe('app', function(){15 describe('.engine(ext, fn)', function(){16 it('should map a template engine', function(done){17 var app = express();18

Merge tag '4.15.2'Douglas Christopher Wilsonbefore adoptione5dbb0c

line 19why, one step back
19 app.set('views', path.join(__dirname, 'fixtures'))

deps: serve-static@~1.3.2Douglas Christopher Wilsonbefore adoptiond29cf4d

lines 20–39why, one step back
20 app.engine('.html', render);
21 app.locals.user = { name: 'tobi' };2223 app.render('user.html', function(err, str){24 if (err) return done(err);25 str.should.equal('<p>tobi</p>');26 done();27 })28 })2930 it('should throw when the callback is missing', function(){31 var app = express();32 (function(){33 app.engine('.html', null);34 }).should.throw('callback function required');35 })3637 it('should work without leading "."', function(done){38 var app = express();39

Merge tag '4.15.2'Douglas Christopher Wilsonbefore adoptione5dbb0c

line 40why, one step back
40 app.set('views', path.join(__dirname, 'fixtures'))

deps: serve-static@~1.3.2Douglas Christopher Wilsonbefore adoptiond29cf4d

lines 41–49why, one step back
41 app.engine('html', render);
42 app.locals.user = { name: 'tobi' };4344 app.render('user.html', function(err, str){45 if (err) return done(err);46 str.should.equal('<p>tobi</p>');47 done();48 })49 })

Merge tag '4.15.4'Douglas Christopher Wilsonbefore adoptionc319fe2

line 50why, one step back
50

deps: serve-static@~1.3.2Douglas Christopher Wilsonbefore adoptiond29cf4d

lines 51–53why, one step back
51 it('should work "view engine" setting', function(done){
52 var app = express();53

Merge tag '4.15.2'Douglas Christopher Wilsonbefore adoptione5dbb0c

line 54why, one step back
54 app.set('views', path.join(__dirname, 'fixtures'))

deps: serve-static@~1.3.2Douglas Christopher Wilsonbefore adoptiond29cf4d

lines 55–64why, one step back
55 app.engine('html', render);
56 app.set('view engine', 'html');57 app.locals.user = { name: 'tobi' };5859 app.render('user', function(err, str){60 if (err) return done(err);61 str.should.equal('<p>tobi</p>');62 done();63 })64 })

Merge tag '4.15.4'Douglas Christopher Wilsonbefore adoptionc319fe2

line 65why, one step back
65

deps: serve-static@~1.3.2Douglas Christopher Wilsonbefore adoptiond29cf4d

lines 66–68why, one step back
66 it('should work "view engine" with leading "."', function(done){
67 var app = express();68

Merge tag '4.15.2'Douglas Christopher Wilsonbefore adoptione5dbb0c

line 69why, one step back
69 app.set('views', path.join(__dirname, 'fixtures'))

deps: serve-static@~1.3.2Douglas Christopher Wilsonbefore adoptiond29cf4d

lines 70–81why, one step back
70 app.engine('.html', render);
71 app.set('view engine', '.html');72 app.locals.user = { name: 'tobi' };7374 app.render('user', function(err, str){75 if (err) return done(err);76 str.should.equal('<p>tobi</p>');77 done();78 })79 })80 })81})