posthtml-class-to-css-module v0.1.3
class to css module
A posthtml A posthtml plugin for clone
class
to attributecss-module
Why?
The plugin for cloning classes in the attribute css-module
when used together with posthtml-css-modules
Install
npm i -D posthtml posthtml-class-to-css-module
Note: This project is compatible with node v4+
Usage
import {readFileSync, writeFileSync} from 'fs';
import posthtml from 'posthtml';
import clone from 'posthtml-class-to-css-module';
const html = readFileSync('input.html', 'utf8');
posthtml()
.use(clone())
.process(html)
.then(result => {
writeFileSync('output.html', result.html);
});
Returns the html with cloned classes in the attribute css-module
Example
input.html
<!DOCTYPE html>
<html>
<head></head>
<body class="class-for-body"></body>
</html>
output.html
<!DOCTYPE html>
<html>
<head></head>
<body class="class-for-body" css-module="class-for-body"></body>
</html>
Options
removeClass
Type: Boolean
Default: false
Description: Removes the class
attribute after cloning the class
value to an attribute css-module
LICENSE
MIT License (MIT)
Copyright (c) Ivan Demidov scrum@list.ru
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.