gulp-lb-include
v0.3.1
Published
Gulp plugin for `#include`-ing HTML files inside other HTML files, using `lb-include`
Downloads
35
Maintainers
Readme
gulp-lb-include
Library for using lb-include
as a gulp
plugin
Builds hosted by Travis CI:
master
: ,
develop
:
Install
$ npm install --save-dev gulp-lb-include
Getting Started
It's easy to use!
var gulp = require('gulp');
var lbInclude = require('gulp-lb-include');
gulp.task('include', function ()
{
return gulp.src('app/**/*.html')
.pipe(lbInclude())
.pipe(gulp.dest('build/'));
});
You can also npm install
and use gulp-plumber
to tidily log
any errors that might get emitted, instead of having to trap and log them yourself:
var gulp = require('gulp');
var plumber = require('gulp-plumber');
var lbInclude = require('gulp-lb-include');
gulp.task('include', function ()
{
return gulp.src('app/**/*.html')
.pipe(plumber())
.pipe(lbInclude())
.pipe(gulp.dest('build/'));
});
Configuration
You can pass an optional configuration object, which will be passed through to lb-include
.
gulp.task('include-with-opts', function ()
{
return gulp.src('app/**/*.html')
.pipe(lbInclude({ varDefaults: {...} }))
.pipe(gulp.dest('build/'));
});
You can pass any option supported by lb-include
(see the documentation for lb-include
for the entire list), aside from fileContents
. This plugin will set fileContents
to the file contents provided by gulp
.
Root Directory
In the examples above, the base
directory
from gulp.src
will be used to resolve root-relative #include
s like <!-- #include file="/templates/nav.html" -->
By default, the base
directory in gulp.src
is everything before the glob
pattern (see the README for
glob2base
for details).
If you wish to use a different directory for resolving root-relative #include
s, you can do so by passing
the root
option to lb-include
gulp.task('include-custom-root', function ()
{
return gulp.src('app/subdir/**/*.html')
.pipe(lbInclude({ root: 'app/' }))
.pipe(gulp.dest('build/'));
});
Tests
To run the tests, checkout this repo and then npm install && npm test
.
To rerun the tests automatically as you edit files, use npm run test-watch
instead.
License
Released under the MIT license © Jeffrey Stanton
See LICENSE.md for full license text