Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

readme.md

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>

About

Spaceless tag to remove whitespace between HTML tags

Topics

Resources

License

Packages

No packages published
You can’t perform that action at this time.