priv-js
Helper library, that contains functions and methods which will help you form final BEMJSON object in *.priv.js
files.
Install
npm install priv-js
Usage
var Blocks = ;var blocks = ;
All *.priv.js
files exports function:
// button.priv.jsmodule { // ...};
This function expects to get instance of priv-js
object in first argument:
var privFile = ;;
API
Blocks()
Constructor. Returns Blocks
instance, that have next methods:
blocks.declare(name, object)
Declares object by name.
blocksdeclare'header' { return block: 'header' content: dataname }; blocksdeclare'utils' format: { ... } { ... };
blocks.has(name)
Checks whether block is declared or not.
blocksdeclare'layout-vertical' { return block: 'layout-vertical' ;};blocksdeclare'layout' { if blocks return blocks; return block: 'layout' ;};
blocks.get(name)
Get declared object by name.
blocksdeclare'price' { var utils = blocks; return block: 'price' content: utils + 'руб.' };
blocks.exec(name, args...)
Executes stored function with args
. If type of stored object is not a function, exception will be thrown. Returns result of execution.
blocksdeclare'item' { return block: 'image' blocks; blocks; };
Changelog
Changelog can be viewed on a separate page.
Contribution
Please, read contribution guide before creating issues or submitting pull request.
Tests
$ npm test