{"id":23156466,"url":"https://github.com/thecreation/inject-string","last_synced_at":"2026-05-02T19:32:44.732Z","repository":{"id":57274008,"uuid":"65793740","full_name":"thecreation/inject-string","owner":"thecreation","description":null,"archived":false,"fork":false,"pushed_at":"2016-08-18T08:40:37.000Z","size":23,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-02T02:26:29.134Z","etag":null,"topics":["nodejs","string","template"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thecreation.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-08-16T06:32:42.000Z","updated_at":"2017-02-16T17:19:39.000Z","dependencies_parsed_at":"2022-09-17T10:12:43.460Z","dependency_job_id":null,"html_url":"https://github.com/thecreation/inject-string","commit_stats":null,"previous_names":["amazingsurge/inject-string"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/thecreation/inject-string","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecreation%2Finject-string","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecreation%2Finject-string/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecreation%2Finject-string/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecreation%2Finject-string/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thecreation","download_url":"https://codeload.github.com/thecreation/inject-string/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecreation%2Finject-string/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32547645,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-02T19:18:06.202Z","status":"ssl_error","status_checked_at":"2026-05-02T19:16:21.335Z","response_time":132,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nodejs","string","template"],"created_at":"2024-12-17T21:13:45.313Z","updated_at":"2026-05-02T19:32:44.713Z","avatar_url":"https://github.com/thecreation.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# inject-string [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Coverage percentage][coveralls-image]][coveralls-url]\n\n\u003e Inject a snippet of code or content into a string.\n\n## Installation\n\nInstall with [npm](https://www.npmjs.com/)\n\n```sh\n$ npm install --save inject-string\n```\n\n## Usage\n\n```js\nvar InjectString = require('inject-string');\n\nvar inject = new InjectString('before \u003c!-- snippet --\u003e after');\ninject.append('foo');\n//=\u003e 'before \u003c!-- snippet --\u003e\\nfoo\\n\u003c!-- endsnippet --\u003e after'\n```\n\n## Actions\n###append\n\n```js\nvar inject = new InjectString('before \u003c!-- snippet --\u003efoo\u003c!-- endsnippet --\u003e after');\ninject.append('bar');\n//=\u003e 'before \u003c!-- snippet --\u003e\\nfoobar\\n\u003c!-- endsnippet --\u003e after'\n```\n\n### prepend\n\n```js\nvar inject = new InjectString('before \u003c!-- snippet --\u003efoo\u003c!-- endsnippet --\u003e after');\ninject.prepend('bar');\n//=\u003e 'before \u003c!-- snippet --\u003e\\nbarfoo\\n\u003c!-- endsnippet --\u003e after'\n```\n\n### replace\n\n```js\nvar inject = new InjectString('before \u003c!-- snippet --\u003efoo\u003c!-- endsnippet --\u003e after');\ninject.replace('bar');\n//=\u003e 'before \u003c!-- snippet --\u003e\\nbar\\n\u003c!-- endsnippet --\u003e after'\n```\n\n### strip\n\n```js\nvar inject = new InjectString('before \u003c!-- snippet --\u003efoo\u003c!-- endsnippet --\u003e \u003c!-- custom --\u003ebar\u003c!-- endcustom --\u003e after');\ninject.strip('custom');\n//=\u003e 'before \u003c!-- snippet --\u003efoo\u003c!-- endsnippet --\u003e bar after'\n```\n\n### stripAll\n\n```js\nvar inject = new InjectString('before \u003c!-- snippet --\u003efoo\u003c!-- endsnippet --\u003e \u003c!-- custom --\u003ebar\u003c!-- endcustom --\u003e after');\ninject.stripAll();\n//=\u003e 'before foo bar after'\n```\n\n## Static call\n\n### inject\n\n```js\nInjectString.inject('a \u003c!-- snippet --\u003e b', 'foo', {stripTags: true});\n//=\u003e 'a foo b'\n```\n\n### strip\n\n```js\nInjectString.strip('before \u003c!-- snippet --\u003efoo\u003c!-- endsnippet --\u003e \u003c!-- custom --\u003ebar\u003c!-- endcustom --\u003e after', {tag:'custom'});\n//=\u003e 'before \u003c!-- snippet --\u003efoo\u003c!-- endsnippet --\u003e bar after'\n```\n\n### stripAll\n\n```js\nInjectString.stripAll('before \u003c!-- snippet --\u003efoo\u003c!-- endsnippet --\u003e \u003c!-- custom --\u003ebar\u003c!-- endcustom --\u003e after');\n//=\u003e 'before foo bar after'\n```\n\n## Options\n### Keep placeholders\n\nInject a snippet into a string with placeholders (used for subsequent insertions):\n\n```js\nvar inject = new InjectString('before \u003c!-- snippet --\u003e after');\ninject.append('foo', {\n  stripTags: false\n});\n//=\u003e 'before \u003c!-- snippet --\u003efoo\u003c!-- endsnippet --\u003e after'\n```\n\n### Strip placeholders\n\nInject a snippet into a string without placeholders:\n\n```js\nvar inject = new InjectString('before \u003c!-- snippet --\u003e after');\ninject.append('foo', {\n  stripTags: true\n});\n//=\u003e 'before foo after'\n```\n\n### Use a custom tag name\n\nCustomize the placeholder name:\n\n```js\nvar inject = new InjectString('before \u003c!-- xyz --\u003e after');\ninject.append(str, 'foo', {tag: 'xyz'})\n//=\u003e 'before foo after'\n```\n\n\n### Use custom delimiters\n\nCustomize the placeholder delimiters:\n\n```js\nvar str = new InjectString('a {{!snippet}} b', {delimiters: ['{{!', '}}']});\nvar result = inject.append('foo');\n//=\u003e 'a {{! snippet }}foo{{! endsnippet }} b'\n```\n\n### Add newlines around snippet\n\n```js\nvar inject = new InjectString('a \u003c!-- snippet --\u003e b', {newlines: true});\nvar result = inject.append('foo');\n//=\u003e 'a \u003c!-- snippet --\u003e\\nfoo\\n\u003c!-- endsnippet --\u003e b'\n```\n\n**Specify lines**\n```js\nvar inject = new InjectString('a \u003c!-- snippet --\u003e b', {newlines: 2});\nvar result = inject.append('foo');\n//=\u003e 'a \u003c!-- snippet --\u003e\\n\\nfoo\\n\\n\u003c!-- endsnippet --\u003e b'\n```\n\n**Specify lines for before and after separately**\n```js\nvar inject = new InjectString('a \u003c!-- snippet --\u003e b', {newlines: '1,2'});\nvar result = inject.append('foo');\n//=\u003e 'a \u003c!-- snippet --\u003e\\nfoo\\n\\n\u003c!-- endsnippet --\u003e b'\n```\n\n## Running tests\n\nInstall dev dependencies:\n\n```sh\n$ npm install -d \u0026\u0026 npm test\n```\n\n## Contributing\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/amazingSurge/inject-string/issues/new)\n\n## Credits\nThis library is based on [inject-snippet](https://github.com/jonschlinkert/inject-snippet).\n\n## License\n\nMIT © [amazingSurge](amazingSurge.com)\n\n[npm-image]: https://badge.fury.io/js/inject-string.svg\n[npm-url]: https://npmjs.org/package/inject-string\n[travis-image]: https://travis-ci.org/amazingSurge/inject-string.svg?branch=master\n[travis-url]: https://travis-ci.org/amazingSurge/inject-string\n[daviddm-image]: https://david-dm.org/amazingSurge/inject-string.svg?theme=shields.io\n[daviddm-url]: https://david-dm.org/amazingSurge/inject-string\n[coveralls-image]: https://coveralls.io/repos/amazingSurge/inject-string/badge.svg\n[coveralls-url]: https://coveralls.io/r/amazingSurge/inject-string\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecreation%2Finject-string","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthecreation%2Finject-string","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecreation%2Finject-string/lists"}