Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions lib/consolidate.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,15 @@ function readPartials(path, options, fn) {
function next(index) {
if (index == keys.length) return fn(null);
var key = keys[index];
var file = join(dirname(path), partials[key] + extname(path));
read(file, options, function(err, str){
if (err) return fn(err);
options.partials[key] = str;
next(++index);
fs.exists(partials[key], function (exists) {
var file = exists
? partials[key]
: join(dirname(path), partials[key] + extname(path));
read(file, options, function(err, str){
if (err) return fn(err);
options.partials[key] = str;
next(++index);
});
});
}

Expand Down
10 changes: 10 additions & 0 deletions test/shared/partials.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

var cons = require('../../')
, fs = require('fs')
, npath = require('path')
, readFile = fs.readFile
, readFileSync = fs.readFileSync;

Expand All @@ -23,6 +24,15 @@ exports.test = function(name) {
done();
});
});
it('should support partials with absolute path', function(done){
var path = npath.join(__dirname, '../fixtures/', name, '/partials.'+name);
var locals = { user: user, partials: { partial: 'user' } };
cons[name](path, locals, function(err, html){
if (err) return done(err);
html.should.equal('<p>Tobi</p>');
done();
});
});
}
else {
it('should support rendering a partial', function(done){
Expand Down