Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including bemjson-to-html with all npm packages installed. Try it out:

var bemjsonToHtml = require("bemjson-to-html")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

bemjson-to-html v0.3.0

BEMJSON to HTML serializer

bemjson-to-html NPM version Build Status Dependency Status

BEMJSON to HTML serializer

This is optimized part of jsot-bh for generation HTML from constructed BEMJSON.

API

new BEMJSON([options])

Creates serializer object.

Options:

  • jsAttrScheme Boolean - 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).

BEMJSON.toHtml(bemjson)

Returns serialized HTML string.

Benchmark

trivial
4,133,717 op/s » bemjson-to-html
2,371,357 op/s » bh

simple
109,658 op/s » bemjson-to-html
78,604 op/s » bh

full
27,264 op/s » bemjson-to-html
23,367 op/s » bh

stringify
1,508,587 op/s » stringify (no escaping)
843,899 op/s » stringify (escaped with replace)
388,025 op/s » stringify (escaped)
312,156 op/s » bemjson-to-html
220,219 op/s » bh

License

MIT (c) Vesvolod Strukchinsky

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free