Skip to content

gulp plugin. Analyze the HTML and retrieve a part of it.

License

Notifications You must be signed in to change notification settings

katsube/gulp-html-takeout

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gulp-html-takeout

This is the Gulp plugin which extracts only the part specified by CSS selector. (CSSセレクターで指定した部分のみを取り出すGulpプラグインです。)

install

npm install --save-dev gulp-html-takeout

Example

gulpfile.js

var gulp    = require("gulp");
var takeout = require("gulp-html-takeout");
var concat  = require("gulp-concat");

gulp.task('default',function(){
	return gulp.src(['sample/*.html'])
		.pipe(takeout('h1'))
		.pipe(concat('bundle.html'))
		.pipe(gulp.dest('dist/'));
});

sample/hello.html

<h1>Hello</h1>

sample/world.html

<h1>World</h1>

dist/bundle.html

Hello
World

API

takeout(option)

option

Set CSS Seletor. If not specified, "body" is the default.

   // == "body"
   .pipe(takeout())
   
   // HTML element
   .pipe(takeout("html"))
   .pipe(takeout("head"))
   .pipe(takeout("h1"))
   
   //Class and ID
   .pipe(takeout(".foo"))
   .pipe(takeout("#bar"))

If more than one HTML Element is applicable

gulp.task('default',function(){
	return gulp.src(['sample/*.html'])
		.pipe(takeout('h1'))
		.pipe(concat('bundle.html'))
		.pipe(gulp.dest('dist/'));
});

sample/foo.html

<h1>Hello</h1>
<h1>World</h1>

dist/bundle.html

HelloWorld

License

MIT License

About

gulp plugin. Analyze the HTML and retrieve a part of it.

Resources

License

Stars

Watchers

Forks

Packages

No packages published