Support layout: false to override a default layout

This commit is contained in:
John Firebaugh 2016-02-14 11:36:29 -08:00
parent 4f4577511f
commit 2f275dbf56
6 changed files with 22 additions and 5 deletions

View file

@ -31,9 +31,5 @@ function check(files, file, pattern, def){
} }
// Only process files with a specified layout // Only process files with a specified layout
if(!data.layout && !def) { return 'layout' in data ? data.layout : def;
return false;
}
return true;
} }

View file

@ -0,0 +1 @@
has no layout

View file

@ -0,0 +1 @@
has no layout

View file

@ -0,0 +1,2 @@
{{title}}
{{contents}}

View file

@ -0,0 +1,5 @@
---
title: Title
layout: false
---
has no layout

View file

@ -149,6 +149,18 @@ describe('metalsmith-layouts', function(){
}); });
}); });
it('should ignore files with layout: false', function(done){
Metalsmith('test/fixtures/layout-false')
.use(layouts({engine: 'handlebars', default: 'default.html'}))
.build(function(err){
if (err) {
return done(err);
}
equal('test/fixtures/layout-false/expected', 'test/fixtures/layout-false/build');
done();
});
});
it('should not change file extension by default', function(done) { it('should not change file extension by default', function(done) {
Metalsmith('test/fixtures/rename-option-default') Metalsmith('test/fixtures/rename-option-default')
.use(layouts({ .use(layouts({