Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript. Learn more »

gulp-append-data

0.0.1 • Public • Published

gulp-append-data

Append content of JSON file to streamed file object. Useful in combination with gulp-consolidate.

Usage

First, install gulp-append-data as a development dependency:

npm install --save-dev gulp-append-data

Then, add it to your gulpfile.js:

var appendData = require('gulp-append-data');
var consolidate = require('gulp-consolidate');
 
gulp.task('html', function(){
    gulp.src(['./app/*.html'])
        .pipe(appendData())
        .pipe(consolidate('swig', function(file) {
                return file.data;
        }))
        .pipe(gulp.dest('./dist'));
});

Now the content of app/test.json will be available when compiling app/test.html.

Example

app/test.json

{
    "foo": "bar"
}

app/test.html

<div>{{ foo }}</div>

dist/test.html

<div>bar</div>

API

appendData(options)

options.property

Type: String

File object property to save the JSON to (optional, defaults to data).

options.getRelativePath

Type: Function

Path of JSON file relative to streamed file (optional, defaults to function(file) { return util.replaceExtension(path.basename(file.path), '.json'); }, see example above).

install

npm i gulp-append-data

Downloadsweekly downloads

2

version

0.0.1

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability