bem-json-to-html
Advanced tools
Comparing version 0.3.2 to 0.3.3
24
index.js
var escape = require('./escape.js'); | ||
var DEFAULT_MOD_SEPARATOR = '_'; | ||
var _jsAttrName = 'onclick'; | ||
@@ -12,3 +14,4 @@ var _defaultTag = 'div'; | ||
options.defaultTag = options.defaultTag || _defaultTag; | ||
options.modificatorSeparator = options.modificatorSeparator || '_'; | ||
options.modificatorSeparator = options.modificatorSeparator || DEFAULT_MOD_SEPARATOR; | ||
options.addDefautTagAttributes = options.addDefautTagAttributes || false; | ||
@@ -25,4 +28,4 @@ this._options = options; | ||
var mods = bemjson.elem ? bemjson.elemMods : bemjson.mods; | ||
var modSep = this._options.modificatorSeparator; | ||
var modSep = this._options && this._options.modificatorSeparator ? this._options.modificatorSeparator : DEFAULT_MOD_SEPARATOR; | ||
if (mods) { | ||
@@ -135,2 +138,17 @@ for (var i in mods) { | ||
var tag = bemjson.tag; | ||
if (this._options.addDefautTagAttributes) { | ||
if (tag === 'img') { | ||
res += ' src="#" alt="" '; | ||
} | ||
if (tag === 'a') { | ||
res += ' href="#" '; | ||
} | ||
if (tag === 'source') { | ||
res += ' src="#" '; | ||
} | ||
} | ||
if (tag === 'area' || | ||
@@ -137,0 +155,0 @@ tag === 'base' || |
{ | ||
"name": "bem-json-to-html", | ||
"version": "0.3.2", | ||
"version": "0.3.3", | ||
"description": "BEMJSON to HTML serializer", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "mocha -R spec" | ||
"test": "mocha -R spec", | ||
"bundle": "browserify index.js --s BEMJSON > bundle.js" | ||
}, | ||
@@ -27,2 +28,3 @@ "repository": { | ||
"bh": "^3.2.2", | ||
"browserify": "^14.5.0", | ||
"enb": "^0.13.4", | ||
@@ -29,0 +31,0 @@ "matcha": "^0.6.0", |
@@ -6,2 +6,4 @@ # bemjson-to-html | ||
[DEMO](https://pvoznyuk.github.io/bemjson-to-html/) | ||
## API | ||
@@ -19,6 +21,7 @@ | ||
* `jsAttrScheme` _Boolean_ - If `js`, attribute with js params will be prefixed with `return ` (default: `js`). | ||
* `jsAttrScheme` _String_ - If `js`, attribute with js params will be prefixed with `return ` (default: `js`). | ||
* `jsAttrName` _String_ - Specifies name of attribute, that will contain `jsParams` (default: `onclick`). | ||
* `defaultTag` _String_ - Default tag name for block without `tag` property (default: `div`). | ||
* `modificatorSeparator` _String_ - Suffix to use for mods instead of default `_` one. (E.g. `{modificatorSeparator: '--'}`). | ||
* `addDefautTagAttributes` _Boolean_ - Add default tags attributes like `src`, `href` (defaukt: `false`). | ||
@@ -25,0 +28,0 @@ ### BEMJSON.toHtml(bemjson) |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
18395
7
310
59
6
2