A gulp plugin for adding headers and footers to your files
Install with npm.
npm install --save-dev gulp-headerfooter
Filenames as the header & footer
var gulp = require('gulp');
var headerfooter = require('gulp-headerfooter');
gulp.task('default', function () {
gulp.src('./app/content')
.pipe(headerfooter.header('./app/partials/header.html'))
.pipe(headerfooter.footer('./app/partials/footer.html'))
.pipe(gulp.dest('./public/'));
});
Strings as the header & footer
var gulp = require('gulp');
var headerfooter = require('gulp-headerfooter');
gulp.task('default', function () {
gulp.src('./app/content')
.pipe(headerfooter.header('<html><body>'))
.pipe(headerfooter.footer('</body></html>'))
.pipe(gulp.dest('./public/'));
});
Buffers as the header & footer
var gulp = require('gulp');
var headerfooter = require('gulp-headerfooter');
var fs = require('fs');
var header = fs.readFileSync('./app/partials/header.html');
var footer = fs.readFileSync('./app/partials/footer.html');
gulp.task('default', function () {
gulp.src('./app/content')
.pipe(headerfooter.header(header))
.pipe(headerfooter.footer(footer))
.pipe(gulp.dest('./public/'));
});
Short hand version
var gulp = require('gulp');
var headerfooter = require('gulp-headerfooter');
gulp.task('default', function () {
gulp.src('./app/content')
.pipe(headerfooter('<html><body>', '</body></html>')
.pipe(gulp.dest('./public/'));
});
Run the units tests with
npm test