diff --git a/.verb.md b/.verb.md index e264567..6687bf9 100644 --- a/.verb.md +++ b/.verb.md @@ -4,18 +4,37 @@ {%= include("install-npm", {save: true}) %} -## Running tests -{%= include("tests") %} - ## Usage ```js -var gulpRoutes = require('{%= name %}'); +var gulpRoutes = require('gulp-routes'); +var Router = require('en-route').Router; +var router = new Router(); + +// define middleware +router.all(/\.hbs/, function (file, next) { + var str = file.contents.toString(); + // do anything to `file` that can be done + // in a gulp plugin + file.contents = new Buffer(str); + next(); +}); + +// pass the router tp `gulpRoutes` +var routes = gulpRoutes(router); + +gulp.src('*.hbs') + .pipe(routes()) + .pipe(gulp.dest('_gh_pages/')); ``` + ## API {%= apidocs("index.js") %} +## Running tests +{%= include("tests") %} + ## Contributing Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue]({%= bugs.url %}) diff --git a/README.md b/README.md index c6c6e1b..6193c5c 100644 --- a/README.md +++ b/README.md @@ -8,20 +8,31 @@ npm i gulp-routes --save ``` -## Running tests -Install dev dependencies. - -```bash -npm i -d && npm test -``` - - ## Usage ```js var gulpRoutes = require('gulp-routes'); +var Router = require('en-route').Router; +var router = new Router(); + +// define middleware +router.all(/\.hbs/, function (file, next) { + var str = file.contents.toString(); + // do anything to `file` that can be done + // in a gulp plugin + file.contents = new Buffer(str); + next(); +}); + +// pass the router tp `gulpRoutes` +var routes = gulpRoutes(router); + +gulp.src('*.hbs') + .pipe(routes()) + .pipe(gulp.dest('_gh_pages/')); ``` + ## API ### [gulpRoutes](./index.js#L32) @@ -49,6 +60,14 @@ gulp.src('*.hbs') ``` +## Running tests +Install dev dependencies. + +```bash +npm i -d && npm test +``` + + ## Contributing Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/assemble/gulp-routes/issues)