# gulp-wrapper

> A gulp plugin for wrapping files with custom strings. Access to filename is given through interpolation.

Latest version **1.0.0** (published 2015-05-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install gulp-wrapper
pnpm add gulp-wrapper
yarn add gulp-wrapper
bun add gulp-wrapper
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2015-05-15 |
| First published | 2014-03-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 14 |
| Author | Antonis Karamitros |
| Maintainers | antouank |
| Keywords | gulp-wrapper, wrap, wrapper, header, footer, gulpplugin |

## Links

- npm: https://www.npmjs.com/package/gulp-wrapper
- Repository: https://github.com/AntouanK/gulp-wrapper
- Homepage: https://github.com/AntouanK/gulp-wrapper#readme
- Issues: https://github.com/AntouanK/gulp-wrapper/issues
- npm.io page: https://npm.io/package/gulp-wrapper

## Dependencies (2)

- [through2](https://npm.io/package/through2.md) ^0.6.5
- [gulp-util](https://npm.io/package/gulp-util.md) ^3.0.4

## Recent versions

- 1.0.0 (latest) — 2015-05-15
- 0.1.5 — 2014-07-22
- 0.1.42 — 2014-06-13
- 0.1.41 — 2014-06-13
- 0.1.4 — 2014-06-06
- 0.1.32 — 2014-03-19
- 0.1.31 — 2014-03-18
- 0.1.3 — 2014-03-18
- 0.1.2 — 2014-03-18
- 0.1.1 — 2014-03-18

## README

gulp-wrapper
============
[![Build Status](https://travis-ci.org/AntouanK/gulp-wrapper.png?branch=master)](https://travis-ci.org/AntouanK/gulp-wrapper) [![NPM version](https://badge.fury.io/js/gulp-wrapper.png)](http://badge.fury.io/js/gulp-wrapper)

> A [Gulp](https://github.com/wearefractal/gulp) plugin for wrapping files with custom strings.
Basically `gulp-header` & `gulp-footer` together.
With the addition that the filename is revealed to the user ( with ${filename} ).

##Usage
For example, on build I can wrap an HTML file with `<script>` template tags and specify the filename id. ( angular templates are a good use case )

sample template file

```
<div>
  <span>my template HTML is here</span>
</div>
```

so in my `gulpfile.js` I can do

```javascript

var gulp    = require('gulp'),
    wrapper = require('gulp-wrapper');

// ...
gulp.src('template.html')
    .pipe(wrapper({
       header: '<script type="text/ng-template" id="${filename}">\n',
       footer: '</script>\n'
    }))
    .pipe(gulp.dest('out'));
```

the result is :
```
<script type="text/ng-template" id="template.html">
<div>
  <span>my template HTML is here</span>
</div>
</script>
```


##API


####options.header
Type: `string` or `function`

The `string` you want to prepend to the file. The file name is available through interpolation `${filename}`

```javascript
//...
gulp.src('script/*.js')
    .pipe(wrapper({ header: '/* ${filename} MyCompany 2014 */'}))
```

A `function` that takes `file` as argument, and returns the string to be the header.
```javascript
//...
gulp.src('script/*.js')
    .pipe(wrapper({ header: function(file){ return '/* '+ file.path +' MyCompany 2014*/'; } }))
```

</br>
####options.footer
Type: `string` or `function`

The `string` you want to append to the file. The file name is available through interpolation `${filename}`

```javascript
//...
gulp.src('script/*.js')
	.pipe(wrapper({ footer: '/* ${filename} MyCompany 2014 */'}))
```
A `function` that takes `file` as argument, and returns the string to be the footer.
```javascript
//...
gulp.src('script/*.js')
    .pipe(wrapper({ footer: function(file){ return '/* '+ file.path +' MyCompany 2014*/'; } }))
```

---
_Source: https://npm.io/package/gulp-wrapper · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
