Merge pull request #82 from GRUBES/master

Replace backslashes in partial names with expected forward slashes
This commit is contained in:
Ismay 2016-05-03 17:23:14 +02:00
commit 61822bd4ef
7 changed files with 32 additions and 1 deletions

View file

@ -36,7 +36,7 @@ function readPartials(partialsRel, layoutsRel, metalsmith) {
var partialAbs = path.join(partialsAbs, name);
var partialPath = path.relative(layoutsAbs, partialAbs);
partials[name] = partialPath;
partials[name.replace(/\\/g, '/')] = partialPath;
}
return partials;

View file

@ -0,0 +1,3 @@
<p>Nav</p>
<p>Content</p>

View file

@ -0,0 +1,3 @@
<p>Nav</p>
<p>Content</p>

View file

@ -0,0 +1,2 @@
{{>nested/nav}}
{{{contents}}}

View file

@ -0,0 +1 @@
<p>Nav</p>

View file

@ -0,0 +1,4 @@
---
layout: layout.html
---
<p>Content</p>

View file

@ -122,6 +122,24 @@ describe('metalsmith-layouts', function(){
});
});
it('should find partials in subdirectories correctly', function(done){
// This test would only fail on Windows if readPartials did not
// replace backslashes in partial names
var instance = Metalsmith('test/fixtures/partials-subdirectories')
.use(layouts({
engine: 'handlebars',
partials: 'layouts/partials'
}));
instance.build(function(err){
if (err) {
return done(err);
}
equal('test/fixtures/partials-subdirectories/expected', 'test/fixtures/partials-subdirectories/build');
done();
});
});
it('should accept a partials option', function(done){
Metalsmith('test/fixtures/partials-option')
.use(layouts({