UNPKG

2.1 kBMarkdownView Raw
1# gulp-wrap [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][depstat-image]][depstat-url]
2
3> A gulp plugin to wrap the stream contents with a lodash template. [gulp](https://github.com/gulpjs/gulp)
4
5## Usage
6
7First, install `gulp-wrap` as a development dependency:
8
9```shell
10npm install --save-dev gulp-wrap
11```
12
13Then, add it to your `gulpfile.js`:
14
15**Wrap the contents with an inline template:**
16
17```javascript
18var wrap = require("gulp-wrap");
19
20gulp.src("./src/*.json")
21 .pipe(wrap('angular.module(\'text\', []).value(<%= contents %>);'))
22 .pipe(gulp.dest("./dist"));
23```
24
25**Wrap the contents with a template from file:**
26
27```javascript
28var wrap = require("gulp-wrap");
29
30gulp.src("./src/*.json")
31 .pipe(wrap({ src: 'path/to/template.txt'}))
32 .pipe(gulp.dest("./dist"));
33```
34
35**Provide additional data and options for template processing:**
36
37```javascript
38var wrap = require("gulp-wrap");
39
40gulp.src("./src/*.json")
41 .pipe(wrap('BEFORE <%= data.contents %> <%= data.someVar %> AFTER', { someVar: 'someVal'}, { variable: 'data' }))
42 .pipe(gulp.dest("./dist"));
43```
44
45## API
46
47### wrap(template\[,data\]\[,options\])
48
49#### template
50Type: `String` or `Object
51
52The 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.
53
54#### template.src
55Type: `String`
56
57The file location of the template.
58
59#### data
60Type: `Object`
61
62The data object that is passed on to the [lodash](http://lodash.com/docs#template) template call.
63
64#### options
65Type: `Object`
66
67The options object that is passed on to the [lodash](http://lodash.com/docs#template) template call.
68
69## License
70
71[MIT License](http://en.wikipedia.org/wiki/MIT_License)
72
73[npm-url]: https://npmjs.org/package/gulp-wrap
74[npm-image]: https://badge.fury.io/js/gulp-wrap.png
75
76[travis-url]: http://travis-ci.org/adamayres/gulp-wrap
77[travis-image]: https://secure.travis-ci.org/adamayres/gulp-wrap.png?branch=master
78
79[depstat-url]: https://david-dm.org/adamayres/gulp-wrap
80[depstat-image]: https://david-dm.org/adamayres/gulp-wrap.png