# inject-snippet

> Inject a snippet of code or content into a string.

Latest version **0.3.0** (published 2015-08-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install inject-snippet
pnpm add inject-snippet
yarn add inject-snippet
bun add inject-snippet
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2015-08-17 |
| First published | 2015-08-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Jon Schlinkert |
| Maintainers | jonschlinkert, doowb |
| Keywords | add, block, cli, code, inject, insert, replace, snippet |

## Links

- npm: https://www.npmjs.com/package/inject-snippet
- Repository: https://github.com/jonschlinkert/inject-snippet
- Issues: https://github.com/jonschlinkert/inject-snippet/issues
- npm.io page: https://npm.io/package/inject-snippet

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads
- [datasets-fi-postalcodes](https://npm.io/package/datasets-fi-postalcodes.md) — 1.1K weekly downloads

## Recent versions

- 0.3.0 (latest) — 2015-08-17
- 0.2.1 — 2015-08-17
- 0.2.0 — 2015-08-17
- 0.1.1 — 2015-08-15
- 0.1.0 — 2015-08-13

## README

# inject-snippet [![NPM version](https://badge.fury.io/js/inject-snippet.svg)](http://badge.fury.io/js/inject-snippet)

> Inject a snippet of code or content into a string.

## Install

Install with [npm](https://www.npmjs.com/)

```sh
$ npm i inject-snippet --save
```

## Usage

```js
var inject = require('inject-snippet');
```

**Keep placeholders**

Inject a snippet into a string with placeholders (used for subsequent insertions):

```js
var str = 'before <!-- snippet --> after';
inject(str, 'foo');
//=> 'before <!-- snippet -->\nfoo\n<!-- endsnippet --> after'
```

**Strip placeholders**

Inject a snippet into a string without placeholders:

```js
var str = 'before <!-- snippet --> after';
inject(str, 'foo', {stripTags: true})
//=> 'before foo after'
```

**Use a custom tag name**

Customize the placeholder name:

```js
var str = 'before <!-- xyz --> after';
inject(str, 'foo', {tag: 'xyz'})
//=> 'before foo after'
```

**Use custom delimiters**

Customize the placeholder delimiters:

```js
var str = '<body>\n\n</body>';
inject(str, 'foo', {delimiters: ['']});
// results in:
// <body>
// foo
// </body>
```

## Related projects

* [assemble](http://assemble.io): Static site generator for Grunt.js, Yeoman and Node.js. Used by Zurb Foundation, Zurb Ink, H5BP/Effeckt,… [more](http://assemble.io)
* [boilerplate](https://github.com/jonschlinkert/boilerplate): Easily create, share and use boilerplates for node.js and web projects.
* [snippet](https://github.com/jonschlinkert/snippet): CLI and API for easily creating, reusing, sharing and generating snippets of code from the… [more](https://github.com/jonschlinkert/snippet)
* [scaffold](https://github.com/jonschlinkert/scaffold): Generate a project or files from scaffolds.
* [verb](https://github.com/assemble/verb): Documentation generator for GitHub projects. Extremely powerful, easy to use, can generate anything from API… [more](https://github.com/assemble/verb)

## Running tests

Install dev dependencies:

```sh
$ npm i -d && npm test
```

## Contributing

Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/inject-snippet/issues/new)

## Author

**Jon Schlinkert**

+ [github/jonschlinkert](https://github.com/jonschlinkert)
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)

## License

Copyright © 2015 Jon Schlinkert
Released under the MIT license.

***

_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on August 17, 2015._

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