selector2tag

v0.1.0
Utility function to build individual HTML tags from CSS selectors.
utility selector

selector2tag

Utility function to build individual HTML tags from CSS selectors. Uses Slick's parser for most of the hard work. I should rework it to build multiple tags.

Example

    var sel2tag = require('selector2tag');
    var wrap = sel2tag('main#content.wrapper.foo[role="main"][bar]');
    
    var result = wrap.openingTag + 'Hello World' + wrap.closingTag;

Result:

<main id="content" class="wrapper foo" role="main" bar>Hello World</main>

The tag name defaults to div.

npm i selector2tag

Metadata

  • MIT
  • Whatever
  • Dylan Krepps
  • released 8/22/2014

Downloads

Maintainers