{"id":51021148,"url":"https://github.com/tenorok/bemodeler","last_synced_at":"2026-06-21T16:31:58.489Z","repository":{"id":24578650,"uuid":"27986471","full_name":"tenorok/bemodeler","owner":"tenorok","description":"Data store for i-bem.js","archived":false,"fork":false,"pushed_at":"2015-04-08T11:38:32.000Z","size":268,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-23T04:41:15.838Z","etag":null,"topics":["bem","client"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tenorok.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-12-14T06:56:31.000Z","updated_at":"2023-04-11T15:17:43.000Z","dependencies_parsed_at":"2022-08-22T11:00:58.113Z","dependency_job_id":null,"html_url":"https://github.com/tenorok/bemodeler","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/tenorok/bemodeler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tenorok%2Fbemodeler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tenorok%2Fbemodeler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tenorok%2Fbemodeler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tenorok%2Fbemodeler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tenorok","download_url":"https://codeload.github.com/tenorok/bemodeler/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tenorok%2Fbemodeler/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34618475,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-21T02:00:05.568Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bem","client"],"created_at":"2026-06-21T16:31:58.419Z","updated_at":"2026-06-21T16:31:58.482Z","avatar_url":"https://github.com/tenorok.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bemodeler — Data store for [i-bem.js](http://tenorok.github.io/get-i-bem/)\n\n[:ru: Bemodeler — Хранилище данных для i-bem.js](README.ru.md)\n\nBEM — is methodology for effective web-development. More information at http://ru.bem.info.\n\n[I-bem.js](http://tenorok.github.io/get-i-bem/) — is library for writting client side JavaScript with [BEM](http://ru.bem.info/libs/bem-bl/dev/desktop.sets/i-bem/).\n\n`Bemodeler` — is extension for `i-bem`, which realizing ability to store data of block in separate place and ability to declaration this data in simple models.\n\n## Install\n\n    bower install bemodeler\n\n### Include\n\nFor working `bemodeler` requires `i-bem`, which in turn requires `jquery`.\n\nAfter install `bemodeler` from `bower` by dependencies will be installed the latest version of `i-bem` and `jquery`.\n\nGroup of abovementioned technologies working only in browser, where should be include all three libraries in the following order:\n\n```html\n\u003cscript src=\"bower_components/jquery/dist/jquery.min.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"bower_components/i-bem/i-bem.min.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"bower_components/bemodeler/bemodeler.min.js\"\u003e\u003c/script\u003e\n```\n\n## Usage\n\n`Bemodeler` adds method `model` in `this` each block.\nThis method accepts one or two parameters depending on what gets or sets the value for specified field in the model.\n\nFor example, let's take arbitrary block:\n\n```js\nBEM.decl('block', {});\nvar block = BEM.create('block');\n```\n\nNow lets's add to received instance of the block in the model property `greeter` with the value `hello world`:\n\n```js\nblock.model('greeter', 'hello world'); // → block\n```\n\nAfter call with two parameters, method `model` returns block, for ability write the call chain.\n\nNow values of property `greeter` stored in `bemodeler` and we can get it by calling the method `model` with one parameter:\n\n```js\nblock.model('greeter'); // → 'hello world'\n```\n\n## Declaration models\n\nModels declared similarly as block in `i-bem`:\n\n```js\nBEM.decl('block', {});\nBEM.model('block', {});\n```\n\nModel always should be declared in scope `BEM` even if block was declared in scope `BEM.DOM`:\n\n```js\nBEM.DOM.decl('button', {});\nBEM.model('button', {});\n```\n\nTo declaring model for the block with modifiers `bemodeler` supports syntax similar `i-bem`.\n\nExample declaration of model by the name of block modifier:\n\n```js\nBEM.model({ block: 'component', modName: 'disabled' }, {});\n```\n\nExample declaration of model by the name and value of block modifier:\n\n```js\nBEM.model({ block: 'component', modName: 'type', modVal: 'text' }, {});\n```\n\n### Property `value`\n\nProperty `value` used for preset the default value of data in model declaration.\n\nExample for block `component`:\n\n```js\nBEM.decl('component', {});\n```\n\nDeclaring property `name` with preset value:\n\n```js\nBEM.model('component', {\n    name: { value: 'Jhon' }\n});\n```\n\nThis value will be set for block `component` by default:\n\n```js\nBEM.create('component').model('name'); // → 'Jhon'\n```\n\nIf you need to make certain calculations, it is possible to pass a function in the value of property `value`. Context of this function will be the block:\n\n```js\nBEM.model('component', {\n    name: { value: function() {\n        return this.__self.getName();\n    }}\n});\nBEM.create('component').model('name'); // → 'component'\n```\n\n### Property `get`\n\nFor data processing when trying their getting, in model declaration you can use property `get`.\n\nProperty `get` takes a function, which is passed one parameter — current value of the model for the described property.\n\nExample for block `component`:\n\n```js\nBEM.decl('component', {});\n```\n\nLet's declare property `name` with handler on getting:\n\n```js\nBEM.model('component', {\n    name: {\n        value: 'Steve',\n        get: function(value) {\n            return value.toUpperCase();\n        }\n    }\n});\nBEM.create('component').model('name'); // → 'STEVE'\n```\n\n### Property `set`\n\nFor data processing when setting their values, in model declaration you can use property `set`.\n\nProperty `set` takes a function, which is passed two parameters:\n* new value\n* current value\n\nExample for block `component`:\n\n```js\nBEM.decl('component', {});\n```\n\nLet's declare property `count` with handler on setting value:\n\n```js\nBEM.model('component', {\n    count: {\n        value: 30,\n        set: function(value, currentValue) {\n            return value \u003c 100 ? value : currentValue;\n        }\n    }\n});\nvar component = BEM.create('component');\ncomponent.model('count', 50).model('count'); // → 50\ncomponent.model('count', 150).model('count'); // → 50\n```\n\n## Specifying properties in JS-parameters\n\nData values may be specified in property `model` of JS-parameters block.\n\nExample for block `component`:\n\n```js\nBEM.decl('component', {});\n```\n\nLet's declare model with property `name`:\n\n```js\nBEM.model('component', {\n    name: { value: 'Jhon' }\n});\n```\n\nLet's create an instance of the block `component` with specifying the values for properties of his model.\n\n```js\nvar component = BEM.create('component', { model: {\n    name: 'Steve'\n}});\n```\n\nThe values specified in JS-parameters of block take precedence over the values specified in declaration of model:\n\n```js\ncomponent.model('name'); // → 'Steve'\n```\n\nThe field `model` not available directly in the block parameters:\n\n```js\ncomponent.params.model; // → undefined\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftenorok%2Fbemodeler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftenorok%2Fbemodeler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftenorok%2Fbemodeler/lists"}