pug-plugin-modules
Advanced tools
Comparing version 0.1.0 to 0.2.0
23
index.js
const path = require('path'); | ||
const resolve = require('resolve'); | ||
module.exports = function({ | ||
extensions, | ||
paths, | ||
moduleDirectory, | ||
packageFilter | ||
}) { | ||
module.exports = function(options) { | ||
return { | ||
resolve(filename, source, options) { | ||
return resolve.sync(filename, { | ||
resolve(filename, source, pugOptions) { | ||
return resolve.sync(filename, Object.assign({ | ||
basedir: path.dirname(source), | ||
extensions: extensions || ['.pug', '.jade'], | ||
paths, | ||
moduleDirectory, | ||
packageFilter: packageFilter || pkg => | ||
extensions: ['.pug', '.jade'], | ||
packageFilter: pkg => | ||
Object.assign({}, pkg, { | ||
main: pkg.pug || pkg.main | ||
}) | ||
}); | ||
}, options)); | ||
} | ||
} | ||
} | ||
}; | ||
}; |
{ | ||
"name": "pug-plugin-modules", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Pug plugin for resolving templates in node_modules", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# pug-plugin-modules | ||
Pug plugin for resolving templates in node_modules | ||
## Installation | ||
``` | ||
npm install pug-plugin-modules | ||
``` | ||
Import plugin: | ||
``` | ||
const modulesPlugin = require('pug-plugin-modules'); | ||
``` | ||
then, in your Pug options object: | ||
``` | ||
{ | ||
plugins: [ | ||
modulesPlugin(/*options*/) | ||
] | ||
} | ||
``` | ||
## Usage | ||
The same options as [resolve](https://github.com/substack/node-resolve) are available. PugPluginModules provides the following defaults: | ||
* `baseDir` = directory of source file | ||
* `extensions` = `['.pug', '.jade']` | ||
* `packageFilter` = will first search for `"pug"` and then `"main"` in `package.json` | ||
## License | ||
MIT (http://www.opensource.org/licenses/mit-license.php) |
3841
29
16