0.1.1 • Published 9 years ago

gulp-html-remove v0.1.1

Weekly downloads
63
License
-
Repository
github
Last release
9 years ago

#gulp-html-remove

Cleans out HTML nodes by CSS selectors or attributes.

Installation

npm install --save-dev gulp-html-remove

Usage

Remove nodes by CSS selectors (See cheerio to know about supported selectors).

var gulp = require('gulp'),
    remove = require('gulp-html-remove');

gulp.task('default', function () {
    
    // Will remove any nodes with "to-remove" class.
    gulp.src('./templates/**/*.html')
        .pipe(remove('.to-remove'))
        .pipe(gulp.dest('./tmp'));
        
    // Will remove all nodes with "my-attr" attribute does not equal to "foo"
    gulp.src('./templates/**/*.html')
        .pipe(remove('[my-attr][my-attr!="foo"]'))
        .pipe(gulp.dest('./tmp'));
});

Remove nodes by attributes

var gulp = require('gulp'),
    remove = require('gulp-html-remove');

gulp.task('default', function () {
    
    // Will remove any nodes which contain to-remove="foo" or to-remove="bar" attributes.
    gulp.src('./templates/**/*.html')
        .pipe(remove({ attrs : { 'to-remove' : ['foo', 'bar'] }}))
        .pipe(gulp.dest('./tmp'));
        
    // Will remove any nodes which contain attributes "to-remove1" or "to-remove2" with any values. 
    gulp.src('./templates/**/*.html')
        .pipe(remove({ attrs : ['to-remove1', 'to-remove2'] }))
        .pipe(gulp.dest('./tmp'));
});

License

MIT @ Eugene Gluhotorenko