https://github.com/posthtml/posthtml-spaceless
Spaceless tag to remove whitespace between HTML tags
https://github.com/posthtml/posthtml-spaceless
html plugin posthtml posthtml-plugin spaceless
Last synced: 10 months ago
JSON representation
Spaceless tag to remove whitespace between HTML tags
- Host: GitHub
- URL: https://github.com/posthtml/posthtml-spaceless
- Owner: posthtml
- License: mit
- Created: 2017-01-18T10:38:58.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-12-13T13:25:30.000Z (about 8 years ago)
- Last Synced: 2024-10-29T21:06:07.598Z (over 1 year ago)
- Topics: html, plugin, posthtml, posthtml-plugin, spaceless
- Language: JavaScript
- Homepage:
- Size: 92.8 KB
- Stars: 7
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Changelog: changelog.md
- License: license
Awesome Lists containing this project
README
# posthtml-spaceless
> A [posthtml](https://github.com/posthtml) plugin remove whitespace between HTML tags
[](https://travis-ci.org/posthtml/posthtml-spaceless)[](https://ci.appveyor.com/project/posthtml/posthtml-spaceless)[]()[](https://www.npmjs.com/package/posthtml-spaceless)[](https://david-dm.org/posthtml/posthtml-spaceless)[](https://github.com/sindresorhus/xo)[](https://coveralls.io/r/posthtml/posthtml-spaceless)
[](https://www.npmjs.com/package/posthtml-spaceless)[](https://www.npmjs.com/package/posthtml-spaceless)
## Why?
This tag is based on and compatible with the [Twig `spaceless` tag](http://twig.sensiolabs.org/doc/tags/spaceless.html), [Swig `spaceless` tag](https://voorhoede.github.io/swig/docs/tags/#spaceless) and [Django `spaceless` tag](https://docs.djangoproject.com/en/dev/ref/templates/builtins/#spaceless).
## Install
```bash
npm i -D posthtml posthtml-spaceless
```
> **Note:** This project is compatible with node v4+
## Usage
```js
import {readFileSync, writeFileSync} from 'fs';
import posthtml from 'posthtml';
import spaceless from 'posthtml-spaceless';
const html = readFileSync('input.html', 'utf8');
posthtml()
.use(spaceless())
.process(html)
.then(result => {
writeFileSync('output.html', result.html);
});
```
*Returns the html without whitespace between tags*
## Example
#### input.html
```html
Header
- one
- two
- three
```
#### output.html
```html
Header
- one
- two
- three
```