script-tags
Version:
Parse HTML script tags into JSON.
75 lines (48 loc) • 2.17 kB
Markdown
# script-tags [](https://www.npmjs.com/package/script-tags) [](https://travis-ci.org/jonschlinkert/script-tags)
> Parse HTML script tags into JSON.
- [Install](#install)
- [scripts(html)](#scripts-html-)
- [Related projects](#related-projects)
- [Running tests](#running-tests)
- [Contributing](#contributing)
- [Author](#author)
- [License](#license)
_(TOC generated by [verb](https://github.com/verbose/verb) using [markdown-toc](https://github.com/jonschlinkert/markdown-toc))_
## Install
**Install with [npm](https://www.npmjs.com/)**:
```sh
$ npm install script-tags --save
```
**Install with [bower](bower.io)**:
```bash
bower install script-tags
```
## scripts(html)
* `html`: pass a string of HTML with the script tags to be parsed
* returns an array, an object for each script tag, each with a `attrs` property and a `html` property.
Example:
```js
var scripts = require('script-tags');
console.log(scripts('<script src="bootstrap.js"></script>'));
//=> [{ "attrs": { "src": "bootstrap.js" }, "html": ""}]
```
See [example](./test/example.json).
## Related projects
* [strip-attributes](https://www.npmjs.com/package/strip-attributes): Strip attributes from HTML tags. | [homepage](https://github.com/jonschlinkert/strip-attributes)
* [strip-tags](https://www.npmjs.com/package/strip-tags): Strip specific tags from a string of HTML | [homepage](https://github.com/jonschlinkert/strip-tags)
## 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/script-tags/issues/new).
## Author
**Jon Schlinkert**
* [github/jonschlinkert](https://github.com/jonschlinkert)
* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
## License
Copyright © 2016 [Jon Schlinkert](https://github.com/jonschlinkert)
Released under the MIT license.
***
_This file was generated by [verb](https://github.com/verbose/verb) on January 05, 2016._