https://github.com/posthtml/posthtml-replace
https://github.com/posthtml/posthtml-replace
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/posthtml/posthtml-replace
- Owner: posthtml
- License: mit
- Created: 2019-07-22T14:56:39.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-06-18T22:23:19.000Z (over 5 years ago)
- Last Synced: 2025-06-13T23:27:22.317Z (8 months ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# PostHTML Plugin Boilerplate 
[![NPM][npm]][npm-url]
[![Deps][deps]][deps-url]
[![Build][build]][build-badge]
[![Coverage][cover]][cover-badge]
[![Standard Code Style][style]][style-url]
[![Chat][chat]][chat-badge]
Clone this repo and explain what your plugin do and why thousands of people need it ;)
Before:
``` html
```
After:
``` html
```
## Install
Describe how big guys can install your plugin.
> npm i posthtml-replace --save-dev
## Usage
Plugin for html attribute replacing.
``` js
const fs = require('fs');
const posthtml = require('posthtml');
const posthtmlReplace = require('posthtml-replace');
posthtml()
.use(posthtmlReplace([
{
match: {
tag: 'link'
},
attrs: {
href: {
from: '/assets/css/',
to: './assets/css/'
}
}
},
{
match: {
tag: 'script'
},
attrs: {
src: {
from: '/assets/js/',
to: './assets/js/'
}
}
},
{
match: {
tag: 'img'
},
attrs: {
src: {
from: '/assets/images/',
to: './assets/images/'
}
}
}
], {} ))
.process(html/*, options */)
.then(result => fs.writeFileSync('./after.html', result.html));
```
## Options
Describe all features of your plugin with examples of usage.
### Feature
Before:
``` html
OMG
```
Add option:
``` js
const fs = require('fs');
const posthtml = require('posthtml');
const posthtmlPlugin = require('posthtml-plugin');
posthtml()
.use(posthtmlPlugin({ feature: 'wow' }))
.process(html/*, options */)
.then(result => fs.writeFileSync('./after.html', result.html));
```
After:
``` html
OMG
```
### Contributing
See [PostHTML Guidelines](https://github.com/posthtml/posthtml/tree/master/docs) and [contribution guide](CONTRIBUTING.md).
### License [MIT](LICENSE)
[npm]: https://img.shields.io/npm/v/posthtml.svg
[npm-url]: https://npmjs.com/package/posthtml-replace
[deps]: https://david-dm.org/posthtml/posthtml.svg
[deps-url]: https://david-dm.org/posthtml/posthtml
[style]: https://img.shields.io/badge/code%20style-standard-yellow.svg
[style-url]: http://standardjs.com/
[build]: https://travis-ci.org/posthtml/posthtml.svg?branch=master
[build-badge]: https://travis-ci.org/posthtml/posthtml?branch=master
[cover]: https://coveralls.io/repos/posthtml/posthtml/badge.svg?branch=master
[cover-badge]: https://coveralls.io/r/posthtml/posthtml?branch=master
[chat]: https://badges.gitter.im/posthtml/posthtml.svg
[chat-badge]: https://gitter.im/posthtml/posthtml?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge"