posthtml-boolean-attributes
v0.3.1
Published
Helps to perform transformations with boolean attributes
Downloads
11,427
Readme
PostHTML Plugin Boolean Attributes
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.