gulp-file-includer

1.0.0 • Public • Published

gulp-file-includer NPM version Build status

A file include plugin for gulp 3

Installation

First, install gulp-file-includer as a development dependency:

npm install --save-dev gulp-file-includer

Usage

Add it to your gulpfile.js:

var gulp = require('gulp')
var fileincluder = require('../index')
 
gulp.task('fileincluder', function() {
  gulp.src(['index.html'])
    .pipe(fileincluder())
    .pipe(gulp.dest('./result/'))
});
 
gulp.task('default', function() {
  gulp.run('fileincluder')
})

index.html

<!DOCTYPE html>
<html>
  <body>
  @@include('./view.html')
  @@include('./var.html', {"name": "haoxin", "age": 12345})
  </body>
</html>

view.html

<h1>view</h1>

var.html

<label>@@name</label>
<label>@@age</label>

and the result is:

<!DOCTYPE html>
<html>
  <body>
  <h1>view</h1>
  <label>haoxin</label>
<label>12345</label>
  </body>
</html>

API

gulp-file-includer can be called with a config object with these attributes:

  • prefix (defaults to '@@')
  • suffix (defaults to '')
  • basePath (defaults to '') If specified, the default root for the file path.

License

MIT

Package Sidebar

Install

npm i gulp-file-includer

Weekly Downloads

2

Version

1.0.0

License

MIT

Last publish

Collaborators

  • pictela