npm.io
0.3.0 • Published 10 years ago

inject-snippet

Licence
MIT
Version
0.3.0
Deps
0
Vulns
0
Weekly
0
Stars
9

inject-snippet NPM version

Inject a snippet of code or content into a string.

Install

Install with npm

$ npm i inject-snippet --save

Usage

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

Keep placeholders

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

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

Strip placeholders

Inject a snippet into a string without placeholders:

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

Use a custom tag name

Customize the placeholder name:

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

Use custom delimiters

Customize the placeholder delimiters:

var str = '<body>\n\n</body>';
inject(str, 'foo', {delimiters: ['']});
// results in:
// <body>
// foo
// </body>
  • assemble: Static site generator for Grunt.js, Yeoman and Node.js. Used by Zurb Foundation, Zurb Ink, H5BP/Effeckt,… more
  • boilerplate: Easily create, share and use boilerplates for node.js and web projects.
  • snippet: CLI and API for easily creating, reusing, sharing and generating snippets of code from the… more
  • scaffold: Generate a project or files from scaffolds.
  • verb: Documentation generator for GitHub projects. Extremely powerful, easy to use, can generate anything from API… more

Running tests

Install dev dependencies:

$ npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue

Author

Jon Schlinkert

License

Copyright 2015 Jon Schlinkert Released under the MIT license.


This file was generated by verb-cli on August 17, 2015.

Keywords