html2bemjson
HTML to BEMJSON convertor
Last updated 11 years ago by tadatuta .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install html2bemjson 
SYNC missed versions from official npm registry.

html2bemjson

Converts HTML to BEMJSON.

Installation

npm install html2bemjson --save

Usage

var html2bemjson = require('html2bemjson');
var html = '<div class="b1"><div class="b1__elem1"></div></div>';

html2bemjson.convert(html); // BEMJSON object

html2bemjson.stringify(html);
// {
//     block: 'b1',
//     content: [
//         {
//             block: 'b1',
//             elem: 'elem1'
//         }
//     ]
// }

Options

Both methods can take options object as a second argument:

require('html2bemjson').stringify('<div class="b1 b1--mod">', {
    preserveComments: false,
    naming: { elem: '__', mod: '--' }, // refer to https://en.bem.info/tools/bem/bem-naming/ for details
    indent: '\t'
});

For more examples please refer to test folder.

Current Tags

  • 1.10.0                                ...           latest (9 years ago)

13 Versions

  • 1.10.0                                ...           9 years ago
  • 1.9.0                                ...           11 years ago
  • 1.8.0                                ...           11 years ago
  • 1.7.0                                ...           11 years ago
  • 1.6.1                                ...           11 years ago
  • 1.6.0                                ...           11 years ago
  • 1.5.0                                ...           11 years ago
  • 1.4.0                                ...           11 years ago
  • 1.3.0                                ...           11 years ago
  • 1.2.0                                ...           11 years ago
  • 1.1.0                                ...           11 years ago
  • 1.0.1                                ...           12 years ago
  • 1.0.0                                ...           12 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (0)
None
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |