mariocasciaro / gulp-multinject

Inject scripts, stylesheets and more into templates and htmls, with support for namespaces
MIT License
3 stars 3 forks source link

Build Status NPM version Dependency Status

gulp-multinject

Inject scripts, stylesheets and more into templates and htmls, with support for namespaces.

Install

Install with npm.

npm install --save-dev gulp-multinject

Examples

The example below will scan all the .html and .jade files and will inject the provided scripts and styles.

var gulp = require('gulp');
var gulpMultinject = require('gulp-multinject');

gulp.task('default', function () {
  gulp.src(['assets/**/*.html', 'assets/**/*.jade'])
    .pipe(gulpMultinject([
        'assets/bundle.js',
        'http://example.com/test.js',
        'assets/styles/style.css'
      ],
      'adminNamespace'
    ))
    .pipe(gulp.dest('out/'));
});

For .html files it will inject between the tags:

  <!--INJECT:adminNamespace-->
  <!--END INJECT-->

For .jade files it will inject between the tags:

  //INJECT:adminNamespace
  //END INJECT

At the moment only .html and .jade files are supported by default, but you can override the templates using the templateMap option (or submitting a PR)

API

gulpMultinject(injectList, namespace, options)

Create a new gulp-multinject transform stream.

Arguments

License

MIT @ Mario Casciaro


Bitdeli Badge