Skip to content
Myr

Added support for partial(view, array) as collection

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 8ece01c · Browse files · 5 files+49 added−5 removed
This commit

State

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

Diff stats

5 files+49 added−5 removed

  • tests:+39 added−3 removed
  • other:+10 added−2 removed

5 files+49 added−5 removed

modified:lib/express/view.js+5 added-2 removed
added:test/fixtures/partials/movie.jade+3 added
1li2 .title= movie.title3 .director= movie.director
added:test/fixtures/movies.jade+1 added
1ul!= partial('movie.jade', movies)
modified:test/view.test.js+35 added-3 removed
1 unmodified line
2/**3 * Module dependencies.4 */56var express = require('express');6var express = require('express'),7 connect = require('connect');89module.exports = {10 'test #render()': function(assert){11 var app = express.createServer();
43 unmodified lines
55 'test #partial()': function(assert){56 var app = express.createServer();57 app.set('views', __dirname + '/fixtures');5859 // Auto-assigned local w/ collection option60 app.get('/', function(req, res){61 res.render('items.jade', { locals: { items: ['one', 'two'] }});62 });6162 assert.response(app,63 64 assert.response(app,65 { url: '/' },66 { body: '<html><body><ul><li>one</li><li>two</li></ul></body></html>' });6768 // Auto-assigned local w/ collection array 69 var movies = [70 { title: 'Nightmare Before Christmas', director: 'Tim Burton' },71 { title: 'Avatar', director: 'James Cameron' }72 ];73 app.get('/movies', function(req, res){74 res.render('movies.jade', { locals: { movies: movies }});75 });76 77 var html = [78 '<html>',79 '<body>',80 '<ul>',81 '<li>',82 '<div class="title">Nightmare Before Christmas</div>',83 '<div class="director">Tim Burton</div>',84 '</li>',85 '<li>',86 '<div class="title">Avatar</div>',87 '<div class="director">James Cameron</div>',88 '</li>',89 '</ul>',90 '</body>',91 '</html>'92 ].join('');9394 assert.response(app,95 { url: '/movies' },96 { body: html });97 }98};
modified:.pomo+5 added
72 unmodified lines
73 complete: false74 description: 75 length: 2576 name: view mtime check interval77- !ruby/object:Pomo::Task 78 complete: false79 description: 80 length: 2581 name: next(err) from within view system?