/posthtml-boolean-attributes

Helps to perform transformations with boolean attributes

Primary LanguageJavaScriptMIT LicenseMIT

PostHTML Plugin Boolean Attributes

NPM Deps Build Coverage Standard Code Style

Doesn't set ="" if set to true, If an array is specified, it will not set the value ['customeBooleanAttr'] for the specified attributes and when specifying ['!customeBooleanAttr'] in the array will exclude attributes.

Before:

  <script async></script>

After:

  <script async=""></script>

Install

npm i posthtml posthtml-boolean-attributes

Usage

const fs = require('fs');
const posthtml = require('posthtml');
const booleanAttributes = require('posthtml-boolean-attributes');

posthtml()
    .use(booleanAttributes({ /* options */ }))
    .process(html/*, options */)
    .then(result => fs.writeFileSync('./after.html', result.html));

Options

boolAttrs

Type: Boolean|Array<String|RegExp>
Default: true
Description: Doesn't set ="" if set to true, if an array is specified, it will not set the value ['customeBooleanAttr'] for the specified attributes and when specifying ['!customeBooleanAttr'] in the array will exclude attributes.

Contributing

See PostHTML Guidelines and contribution guide.