Skip to content

Commit

Permalink
fix nested locals rendering with partials
Browse files Browse the repository at this point in the history
  • Loading branch information
aheckmann committed Sep 13, 2011
1 parent f72042e commit 1f573da
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,3 +1,4 @@
*.swp
*.swn
*.swo
node_modules/
5 changes: 3 additions & 2 deletions index.js
Expand Up @@ -98,10 +98,11 @@ function resolve (options, callback, nested) {

// locals support
if (options.locals) {
resolve(options.locals, function (err, resolved) {
return resolve(options.locals, function (err, resolved) {
if (err) return error(err);
options.locals = resolved;
--pending || callback(null, options);
if (--pending) return;
return callback(null, options);
}, true);
}

Expand Down
1 change: 1 addition & 0 deletions test/fixtures/nested-partial.jade
@@ -0,0 +1 @@
li= title
2 changes: 2 additions & 0 deletions test/fixtures/nested.jade
@@ -0,0 +1,2 @@
ul
!= partial('nested-partial')
18 changes: 17 additions & 1 deletion test/index.js
Expand Up @@ -196,6 +196,14 @@ function assignExports () {
});
});

app.get('/renderlocalsonlynest', function (req, res) {
res.render('nested', {
locals: {
title: 'yes'
}
});
});

app.get('/renderbothnesterror', function (req, res) {
res.render('both', {
locals: {
Expand All @@ -207,7 +215,7 @@ function assignExports () {

// test

var pending = 6;
var pending = 7;
function done () {
if (--pending) return;
db.close();
Expand Down Expand Up @@ -254,6 +262,14 @@ function assignExports () {
, done
);

assert.response(app,
{ url: '/renderlocalsonlynest' }
, { status: 200
, body: '<ul><li>yes</li></ul>'
}
, done
);

assert.response(app,
{ url: '/renderqueryerror' }
, function (res) {
Expand Down

0 comments on commit 1f573da

Please sign in to comment.