Skip to content
Myr

view system utilizing `app.locals`

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent 1dc8776 · Browse files · 2 files+7 added−9 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+7 added−9 removed

  • tests:+6 added−8 removed
  • other:+1 added−1 removed

2 files+7 added−9 removed

modified:lib/view.js+1 added-1 removed
333 unmodified lines
334res._render = function(view, opts, fn, parent, sub){335 var options = {}336 , self = this337 , app = this.app338 , locals = app._locals338 , locals = app.locals339 , dynamic = app._dynamicLocals340 , root = app.set('views') || process.cwd() + '/views';341342 // cache id
113 unmodified lines
modified:test/view.test.js+6 added-8 removed
893 unmodified lines
894 { url: '/' },895 { body: '<p>This is actually jade :)</p>' });896 },897898 'test app.local()': function(){898 'test app.locals': function(){899 var app = create();900901 app902 .local('open', '<?')903 .local('close', '?>')904 .local('title', 'Wahoo');901 app.locals.title = 'Wahoo';902 app.locals({ open: '<?', close: '?>' });903904 app.get('/video', function(req, res, next){905 res.render('video.ejs', { layout: false });906 });
35 unmodified lines
942 943 'test res.locals partials': function(){944 var app = create();945948 app.local('site', 'My Cool Pets');946 app.locals.site = 'My Cool Pets';947 948 app.get('/pets', function(req, res, next){949 res.locals.pets = ['Tobi'];950 next();
63 unmodified lines
1014 res.render('hello.jade');1015 });10161017 app.get('/local', function(req, res){1020 res.locals.charse = 'ISO-8859-1';1018 res.locals.charset = 'ISO-8859-1';1019 res.render('hello.jade');1020 });10211022 app.get('/render', function(req, res){
14 unmodified lines
1037 },1038 1039 'test charset override': function(){1040 var app = create();1043 app.set('view options', { charset: 'ISO-8859-1' });1041 app.locals.charset = 'ISO-8859-1';1042 1043 app.get('/', function(req, res){1044 res.render('hello.jade', { charset: 'utf8' });1045 });
6 unmodified lines