diff --git a/lib/consolidate.js b/lib/consolidate.js index 3f664ad..94c6754 100644 --- a/lib/consolidate.js +++ b/lib/consolidate.js @@ -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); + }); }); } diff --git a/test/shared/partials.js b/test/shared/partials.js index 625b76a..b88d2e6 100644 --- a/test/shared/partials.js +++ b/test/shared/partials.js @@ -1,6 +1,7 @@ var cons = require('../../') , fs = require('fs') + , npath = require('path') , readFile = fs.readFile , readFileSync = fs.readFileSync; @@ -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('

Tobi

'); + done(); + }); + }); } else { it('should support rendering a partial', function(done){