A posthtml plugin for clone class to attribute css-module
JavaScript
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
test
.editorconfig
.gitignore
.npmignore
.travis.yml
appveyor.yml
changelog.md
license
package.json
readme.md
yarn.lock

readme.md

posthtml-class-to-css-module

A posthtml A posthtml plugin for clone class to attribute css-module

Travis Build Statusnodenpm versionDependency StatusXO code styleCoveralls status

npm downloadsnpm

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