middleware-utils
Utils for Template middleware.
Install
Install with npm
$ npm i middleware-utils --save
Usage
var utils = require('middleware-utils');
API
Run middleware in series
Params
fns
{Array}: Array of middleware functions
Example
var middleware = require('./middleware/');
template.onLoad(/\.js$/, utils.series([
middleware.foo,
middleware.bar,
middleware.baz,
]));
Run middleware in parallel.
Params
fns
{Array}: Array of middleware functions
Example
var middleware = require('./middleware/');
template.onLoad(/\.js$/, utils.parallel([
middleware.foo,
middleware.bar,
middleware.baz,
]));
Output a formatted middleware error.
Params
methodName
{String}: The middleware method name (verb)
Example
template.postRender(/./, function (file, next) {
next();
}, utils.error('postRender'));
Handle middleware errors for the .handle()
method.
Params
file
{Object}: Vinyl file object or template object.methodName
{String}: The middleware method name (verb)
Example
template.handle('onFoo', file, utils.handleError(file, 'onFoo'));
Related projects
- assemble: Static site generator for Grunt.js, Yeoman and Node.js. Used by Zurb Foundation, Zurb Ink, H5BP/Effeckt,… more
- template: Render templates using any engine. Supports, layouts, pages, partials and custom template types. Use template… more
- template-utils: Utils for Template, and Template-based applications.
- utils: Fast, generic JavaScript/node.js utility functions.
- verb: Documentation generator for GitHub projects. Extremely powerful, easy to use, can generate anything from API… more
Running tests
Install dev dependencies:
$ npm i -d && npm test
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue
Author
Jon Schlinkert
License
Copyright © 2015 Jon Schlinkert
Released under the MIT license.
This file was generated by verb-cli on June 13, 2015.