mirror of
https://github.com/vale981/metalsmith-layouts
synced 2025-03-05 17:41:39 -05:00
Ignore files without a layout
This commit is contained in:
parent
46d20c13f7
commit
5712464e93
9 changed files with 38 additions and 2 deletions
|
@ -107,9 +107,9 @@ function plugin(opts){
|
||||||
debug('converting file: %s', file);
|
debug('converting file: %s', file);
|
||||||
var data = files[file];
|
var data = files[file];
|
||||||
|
|
||||||
// Require a default or a layout to be specified for each file
|
// Ignore files without a specified layout
|
||||||
if(!data.layout && !def) {
|
if(!data.layout && !def) {
|
||||||
throw new Error('No layout specified for ' + file);
|
return done();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deep clone params (by passing 'true')
|
// Deep clone params (by passing 'true')
|
||||||
|
|
6
test/fixtures/ignore/build/layout.html
vendored
Normal file
6
test/fixtures/ignore/build/layout.html
vendored
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
has a layout
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
1
test/fixtures/ignore/build/no-layout.html
vendored
Normal file
1
test/fixtures/ignore/build/no-layout.html
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
has no layout
|
6
test/fixtures/ignore/expected/layout.html
vendored
Normal file
6
test/fixtures/ignore/expected/layout.html
vendored
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
has a layout
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
1
test/fixtures/ignore/expected/no-layout.html
vendored
Normal file
1
test/fixtures/ignore/expected/no-layout.html
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
has no layout
|
5
test/fixtures/ignore/layouts/layout.html
vendored
Normal file
5
test/fixtures/ignore/layouts/layout.html
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
{{contents}}
|
||||||
|
</body>
|
||||||
|
</html>
|
4
test/fixtures/ignore/src/layout.html
vendored
Normal file
4
test/fixtures/ignore/src/layout.html
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
layout: layout.html
|
||||||
|
---
|
||||||
|
has a layout
|
1
test/fixtures/ignore/src/no-layout.html
vendored
Normal file
1
test/fixtures/ignore/src/no-layout.html
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
has no layout
|
|
@ -137,4 +137,16 @@ describe('metalsmith-layouts', function(){
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should ignore files without a layout', function(done){
|
||||||
|
Metalsmith('test/fixtures/ignore')
|
||||||
|
.use(layouts('handlebars'))
|
||||||
|
.build(function(err){
|
||||||
|
if (err) {
|
||||||
|
return done(err);
|
||||||
|
}
|
||||||
|
equal('test/fixtures/ignore/expected', 'test/fixtures/ignore/build');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue