Giter VIP home page Giter VIP logo

gulp-routes's Introduction

gulp-routes NPM version NPM monthly downloads NPM total downloads Linux Build Status

Add middleware to run for specified routes in your gulp pipeline.

Install

Install with npm:

$ npm install --save gulp-routes

Usage

The main export is a function that takes an instance of en-route and returns a gulp plugin function.

Params

  • enRoute {Object}: Instance of en-route.
  • returns {Function}

Example

var routes = 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 to `gulp-routes`
var route = routes(router);

gulp.src('*.hbs')
  .pipe(route())
  .pipe(gulp.dest('_gh_pages/'));

Create a router stream to run middleware for the specified method.

Params

  • method {String}: Method to run middleware.
  • returns {Stream}: Returns a stream for piping files through.

Example

gulp.src('*.hbs')
  .pipe(route('before'))
  .pipe(otherPlugin())
  .pipe(route('after'))
  .pipe(gulp.dest('dist/'));

About

Related projects

You might also be interested in these projects:

  • base-routes: Plugin for adding routes support to your base application. Requires templates support to work. | homepage
  • base: Framework for rapidly creating high quality node.js applications, using plugins like building blocks | homepage
  • en-route: Routing for static site generators, build systems and task runners, heavily based on express.js routes… more | homepage

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Contributors

Commits Contributor
6 jonschlinkert
5 doowb

Building docs

(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)

To generate the readme, run the following command:

$ npm install -g verbose/verb#dev verb-generate-readme && verb

Running tests

Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:

$ npm install && npm test

Author

Brian Woodward

License

Copyright © 2017, Brian Woodward. Released under the MIT License.


This file was generated by verb-generate-readme, v0.6.0, on August 07, 2017.

gulp-routes's People

Contributors

jonschlinkert avatar doowb avatar

Watchers

James Cloos avatar yuriy.deneha avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.