Skip to content
Myr

app.engine.js

This file

Path

test/app.engine.js

81 lines · 2.1 KiB · JavaScript

Last changed by

lint: add eslint rules that cover editorconfigDouglas Christopher Wilsonbefore adoption56e90e3

History of this file

Take it

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

examples: comment the usage of process.nextTickMuhammad Saqibbefore adoptiondd2b897

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

tests: use path.join instead of concatenationchainhelenbefore adoptioneece385

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

examples: comment the usage of process.nextTickMuhammad Saqibbefore adoptiondd2b897

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

tests: use path.join instead of concatenationchainhelenbefore adoptioneece385

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

examples: comment the usage of process.nextTickMuhammad Saqibbefore adoptiondd2b897

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

tests: use path.join instead of concatenationchainhelenbefore adoptioneece385

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

examples: comment the usage of process.nextTickMuhammad Saqibbefore adoptiondd2b897

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 })

lint: add eslint rules that cover editorconfigDouglas Christopher Wilsonbefore adoption56e90e3

line 50why, one step back
50

examples: comment the usage of process.nextTickMuhammad Saqibbefore adoptiondd2b897

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

tests: use path.join instead of concatenationchainhelenbefore adoptioneece385

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

examples: comment the usage of process.nextTickMuhammad Saqibbefore adoptiondd2b897

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 })

lint: add eslint rules that cover editorconfigDouglas Christopher Wilsonbefore adoption56e90e3

line 65why, one step back
65

examples: comment the usage of process.nextTickMuhammad Saqibbefore adoptiondd2b897

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

tests: use path.join instead of concatenationchainhelenbefore adoptioneece385

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

examples: comment the usage of process.nextTickMuhammad Saqibbefore adoptiondd2b897

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})