0.0.3 • Published 6 years ago

posthtml-spaceless v0.0.3

Weekly downloads
8
License
MIT
Repository
github
Last release
6 years ago

posthtml-spaceless

A posthtml plugin remove whitespace between HTML tags

Travis Build StatusAppVeyor Build Statusnodenpm versionDependency StatusXO code styleCoveralls status

npm downloadsnpm

Why?

This tag is based on and compatible with the Twig spaceless tag, Swig spaceless tag and Django spaceless tag.

Install

npm i -D posthtml posthtml-spaceless

Note: This project is compatible with node v4+

Usage

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

<!DOCTYPE html>
<html>
    <head></head>
    <body>
        <h2>Header</h2>
        <spaceless>
        <ul>
            <li>one</li>
            <li>two</li>
            <li>three</li>
        </ul>
        </spaceless>
    </body>
</html>

output.html

<!DOCTYPE html>
<html>
    <head></head>
    <body>
        <h2>Header</h2>
        <ul><li>one</li><li>two</li><li>three</li></ul>
    </body>
</html>