gulp-wrap-layout

0.3.0 • Public • Published

gulp-wrap-layout NPM version

A gulp plugin to wrap the stream contents with an ejs template.

Usage

First, install gulp-wrap-layout as a development dependency:

npm install --save-dev gulp-wrap-layout

Then, add it to your gulpfile.js:

Wrap the contents with an inline template:

var wrap = require("gulp-wrap-layout");
 
gulp.src("./src/*.json")
    .pipe(wrap('angular.module(\'text\', []).value(<%= contents %>);'))
    .pipe(gulp.dest("./dist"));

Wrap the contents with a template from file:

var wrap = require("gulp-wrap-layout");
 
gulp.src("./src/*.json")
    .pipe(wrap({ src: 'path/to/template.txt'}))
    .pipe(gulp.dest("./dist"));

Provide additional data and options for template processing:

var wrap = require("gulp-wrap-layout");
 
gulp.src("./src/*.json")
    .pipe(wrap('BEFORE <%= contents %> <%= data.someVar %> AFTER', { someVar: 'someVal'}, { variable: 'data' }))
    .pipe(gulp.dest("./dist"));

This gulp plugin wraps the stream contents in a template. If you want the stream contents to be the templates use the gulp-template plugin.

Template

The stream contents will be available in the template using the contents key. Properties from the vinyl file will be available in the template under the file object and are local to that stream. User supplied data values will always take precedence over namespace clashes with the file properties.

API

wrap(template[,data][,options])

template

Type: String or Object

The template to used. When a String then it will be used as the template. When an Object then the template will be loaded from file.

template.src

Type: String

The file location of the template.

data

Type: Object

The data object that is passed on to the ejs template call.

options

Type: Object

The options object that is passed on to the ejs template call.

wrap.ejs

Access the ejs object directly

License

MIT License

Package Sidebar

Install

npm i gulp-wrap-layout

Weekly Downloads

0

Version

0.3.0

License

none

Last publish

Collaborators

  • mariusgundersen