posthtml-prefix-ngclass

1.0.2 • Public • Published

posthtml-prefix-ngclass

PostHTML plugin to prefix ng-class names.

Installation

npm install --save-dev posthtml-prefix-ngclass

Usage

const posthtml = require('posthtml');
const posthtmlPrefixNgClass = require('posthtml-prefix-ngclass');
 
posthtml()
    .use(posthtmlPrefixNgClass({
        prefix: 'prefix-'
    }))
    .process(
        `<div ng-class="{ 'has-error': model.$invalid, 'row': vertical }"></div>`
    )
    .then((output) => {
        console.log(output.html);
        // <div ng-class="{'prefix-has-error': model.$invalid,'prefix-row': vertical}"></div>
    });

Options

prefix

Type: String Default: ''

The string used to prefix ng-class names.

ignore

Type: Array|String Default: []

A class name, or an array of class names, to be excluded from prefixing.

const posthtml = require('posthtml');
const posthtmlPrefixNgClass = require('posthtml-prefix-ngclass');
 
posthtml()
    .use(posthtmlPrefixNgClass({
        prefix: 'prefix-',
        ignore: ['row']
    }))
    .process(
        `<div ng-class="{ 'has-error': model.$invalid, 'row': vertical }"></div>`
    )
    .then((output) => {
        console.log(output.html);
        // <div ng-class="{'prefix-has-error': model.$invalid,'row': vertical}"></div>
    });

Testing

npm test

To-Do

Add support for condition/function in square brackets

Package Sidebar

Install

npm i posthtml-prefix-ngclass

Weekly Downloads

0

Version

1.0.2

License

MIT

Last publish

Collaborators

  • loymax