1.0.2 • Published 6 years ago

posthtml-prefix-ngclass v1.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

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