html-class-prefixer

0.0.2 • Public • Published

html-class-prefixer

prefix class names and IDs (optionally) in html strings

how to use

Async

var prefixer = require('html-class-prefixer')
 
var html = '<div id="container"><span onclick=foo class="sdsd test-texg test"></span></div>';
prefixer(html,
          {prefix:'test-', ignore:['test'], prefixIds: true})
  .then(function(val){
    console.log(val)
    // => <div id="test-container"><span onclick=foo class="sdsd test-texg test"></span></div>
  })
  .fail(function(err){
    console.log(err)
    // = > Error
  })
 

sync

var prefixer = require('html-class-prefixer')
 
var html = '<div id="container"><span onclick=foo class="sdsd test-texg test"></span></div>';
var result = prefixer.sync(html, {prefix:'test-', ignore:['test'], prefixIds: true})
// if result is string => successful
// if result is object => Error
 

Notes:

  • pull requests are welcome
  • better docs to come

Package Sidebar

Install

npm i html-class-prefixer

Weekly Downloads

5

Version

0.0.2

License

MIT

Last publish

Collaborators

  • lwhiteley