metalsmith-layouts
Advanced tools
Comparing version 1.6.5 to 1.7.0
@@ -0,1 +1,6 @@ | ||
1.7.0 - November 6, 2016 | ||
------------------- | ||
* expose consolidate.requires fix (#18) | ||
* check if paths are already absolute before joining the metalsmith path | ||
1.6.5 - May 3, 2016 | ||
@@ -2,0 +7,0 @@ ------------------- |
@@ -16,10 +16,10 @@ /** | ||
* | ||
* @param {String} partialsRel | ||
* @param {String} layoutsRel | ||
* @param {String} partialsPath | ||
* @param {String} layoutsPath | ||
* @param {Object} metalsmith | ||
* @return {Object} | ||
*/ | ||
function readPartials(partialsRel, layoutsRel, metalsmith) { | ||
var partialsAbs = path.join(metalsmith.path(), partialsRel); | ||
var layoutsAbs = path.join(metalsmith.path(), layoutsRel); | ||
function readPartials(partialsPath, layoutsPath, metalsmith) { | ||
var partialsAbs = path.isAbsolute(partialsPath) ? partialsPath : path.join(metalsmith.path(), partialsPath); | ||
var layoutsAbs = path.isAbsolute(layoutsPath) ? layoutsPath : path.join(metalsmith.path(), layoutsPath); | ||
var files = read(partialsAbs); | ||
@@ -26,0 +26,0 @@ var partials = {}; |
@@ -33,3 +33,4 @@ /** | ||
'pattern', | ||
'rename' | ||
'rename', | ||
'exposeConsolidate' | ||
]; | ||
@@ -70,2 +71,6 @@ | ||
if (typeof opts.exposeConsolidate === 'function') { | ||
opts.exposeConsolidate(consolidate.requires) | ||
} | ||
// Map options to local variables | ||
@@ -72,0 +77,0 @@ var def = opts.default; |
@@ -6,3 +6,3 @@ { | ||
"repository": "git://github.com/superwolff/metalsmith-layouts.git", | ||
"version": "1.6.5", | ||
"version": "1.7.0", | ||
"license": "MIT", | ||
@@ -9,0 +9,0 @@ "main": "lib/index.js", |
@@ -168,4 +168,4 @@ # metalsmith-layouts | ||
"metalsmith-layouts": { | ||
"engine": "swig", | ||
"pattern": "*.md" | ||
"engine": "handlebars", | ||
"pattern": "**/*.hbs" | ||
} | ||
@@ -176,3 +176,4 @@ } | ||
Would only process files that have the `.md` extension. | ||
Would process all files that have the `.hbs` extension. Beware that the extensions might be changed by other plugins in the build chain, preventing the pattern from matching. | ||
We use [multimatch](https://github.com/sindresorhus/multimatch) for the pattern matching. | ||
@@ -186,3 +187,3 @@ ### rename | ||
"plugins": { | ||
"metalsmith-in-place": { | ||
"metalsmith-layouts": { | ||
"engine": "handlebars", | ||
@@ -197,2 +198,18 @@ "rename": true | ||
### exposeConsolidate | ||
Not available over the `metalsmith.json` file. | ||
Exposes Consolidate.requires as a function. | ||
```js | ||
// ... | ||
.use(layout('swig', { | ||
exposeConsolidate: function(requires) { | ||
// your code here | ||
} | ||
})) | ||
// ... | ||
``` | ||
### Consolidate | ||
@@ -199,0 +216,0 @@ |
@@ -43,2 +43,15 @@ var assert = require('assert'); | ||
it('should expose consolidate.requires', function(done){ | ||
Metalsmith('test/fixtures/basic') | ||
.use(layouts({ engine: 'swig', exposeConsolidate: function(requires) { | ||
assert.deepEqual(requires, require('consolidate').requires); | ||
}})) | ||
.build(function(err){ | ||
if (err) { | ||
return done(err); | ||
} | ||
done(); | ||
}); | ||
}); | ||
it('should accept a default template', function(done){ | ||
@@ -144,2 +157,20 @@ Metalsmith('test/fixtures/default') | ||
it('should find partials in subdirectories with absolute directory path', function(done){ | ||
var instance = Metalsmith('test/fixtures/partials-subdirectories') | ||
.use(layouts({ | ||
engine: 'handlebars', | ||
templates: __dirname + '/fixtures/partials-subdirectories/layouts', | ||
partials: __dirname + '/fixtures/partials-subdirectories/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){ | ||
@@ -146,0 +177,0 @@ Metalsmith('test/fixtures/partials-option') |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
258944
432
240