{"id":17766580,"url":"https://github.com/floatdrop/jsot-bh","last_synced_at":"2025-08-22T23:08:36.173Z","repository":{"id":18738020,"uuid":"21949700","full_name":"floatdrop/jsot-bh","owner":"floatdrop","description":"BH matchers for JSOT templating engine","archived":false,"fork":false,"pushed_at":"2014-08-04T18:03:41.000Z","size":848,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-07T15:51:56.750Z","etag":null,"topics":[],"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/floatdrop.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-07-17T16:42:18.000Z","updated_at":"2014-07-23T15:03:17.000Z","dependencies_parsed_at":"2022-09-26T21:51:32.742Z","dependency_job_id":null,"html_url":"https://github.com/floatdrop/jsot-bh","commit_stats":null,"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floatdrop%2Fjsot-bh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floatdrop%2Fjsot-bh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floatdrop%2Fjsot-bh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floatdrop%2Fjsot-bh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/floatdrop","download_url":"https://codeload.github.com/floatdrop/jsot-bh/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246651508,"owners_count":20811991,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-10-26T20:32:49.152Z","updated_at":"2025-04-01T13:45:14.293Z","avatar_url":"https://github.com/floatdrop.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JSOT-BH [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][depstat-image]][depstat-url] [![Coveralls Status][coveralls-image]][coveralls-url]\n\nThis is modification of [JSOT](https://github.com/floatdrop/jsot) template engine, which provides BH matchers and some other things.\n\n## Migration notice\n\nThis library is not maintained by BH developers and can't be used as as-is replace for `bh` package. __Use with cautition!__\n\n## Matchers\n\n`Matcher` - function passed as second argument to `BH.match`. \n\nIt accepts context object with helper methods (which essential just an instance of JSOT-BH) and current processed object as second argument.\n\nIt can call `applyBase` method of context object, which applies all matchers to current processed object.  \n\nIt can return new object as replacement of current object (useful for wrapping) - which can contain current object in content property or in an arrary.\n\nJSOT-BH will restart apply procedure for returned object until it will be processed with all matchers, that corresponds to this block.\n\n## API\n\nContext methods is similar to [BH](https://github.com/enb-make/bh#%D0%9A%D0%BB%D0%B0%D1%81%D1%81-ctx) specification.\n\n## Usage\n\n```js\nvar JSOTBH = require('./index.js');\nvar jsotbh = new JSOTBH();\n\njsotbh.match('html', function (ctx) {\n    ctx.tag('html');\n});\n\njsotbh.match('p', function (ctx) {\n    ctx.tag('p');\n});\n\njsotbh.match('p_bold_yes', function (ctx) {\n    ctx.cls('boldy');\n});\n\nconsole.log(\n    jsotbh.apply({\n        block: 'html',\n        content: [\n            { block: 'p', content: 'You' },\n            { block: 'p', mods: { bold: 'yes' }, content: 'Rock!' }\n        ]\n    })\n);\n\n// should output: '\u003chtml class=\"html\"\u003e\u003cp class=\"p\"\u003eYou\u003c/p\u003e\u003cp class=\"p p_bold_yes boldy\"\u003eRock!\u003c/p\u003e\u003c/html\u003e'\n```\n\n## Benchmark\n\nThis numbers can be used as \"fastest possible\" BH performance, but not necessary achivable (`jsot-bh` is lacking some functionality - see API status for details).\n\nWhile single block/element rendering is much faster, than BH, real-life pages is rendered with same speed.\n\n```\nBenchmarking applyBase...\n  jsotbh#applyBase      x 135,141 ops/sec ±1.17% (90 runs sampled)\n  bh#applyBase          x  21,956 ops/sec ±2.35% (86 runs sampled)\n\nBenchmarking block matching...\n  jsotbh#block          x 1,059,293 ops/sec ±3.61% (93 runs sampled)\n  bh#block              x    62,714 ops/sec ±2.20% (88 runs sampled)\n\nBenchmarking block_mod matching...\n  jsotbh#block_mod      x 529,408 ops/sec ±0.91% (94 runs sampled)\n  bh#block_mod          x  49,560 ops/sec ±2.65% (80 runs sampled)\n\nBenchmarking element matching...\n  jsotbh#block__elem    x 212,603 ops/sec ±1.20% (92 runs sampled)\n  bh#block__elem        x  47,530 ops/sec ±2.65% (80 runs sampled)\n\nBenchmarking deep bemjsons...\n  jsotbh#deep           x 11,085 ops/sec ±1.12% (92 runs sampled)\n  bh#deep               x  8,311 ops/sec ±1.52% (86 runs sampled)\n\nBenchmarking deepArray bemjsons...\n  jsotbh#deepArray      x 18,638 ops/sec ±1.90% (88 runs sampled)\n  bh#deepArray          x 17,555 ops/sec ±1.34% (84 runs sampled)\n\nBenchmarking block wrapping...\n  jsotbh#wrap           x 201,079 ops/sec ±1.54% (78 runs sampled)\n  bh#wrap               x  48,531 ops/sec ±3.50% (83 runs sampled)\n\nBenchmarking multiple matchers...\n  jsotbh#match_elem     x 1,615,158 ops/sec ±2.50% (81 runs sampled)\n  bh#match_elem         x    73,314 ops/sec ±7.92% (74 runs sampled)\n```\n\n[npm-url]: https://npmjs.org/package/jsot-bh\n[npm-image]: http://img.shields.io/npm/v/jsot-bh.svg\n\n[travis-url]: https://travis-ci.org/floatdrop/jsot-bh\n[travis-image]: http://img.shields.io/travis/floatdrop/jsot-bh.svg\n\n[depstat-url]: https://david-dm.org/floatdrop/jsot-bh\n[depstat-image]: https://david-dm.org/floatdrop/jsot-bh.svg?theme=shields.io\n\n[coveralls-url]: https://coveralls.io/r/floatdrop/jsot-bh\n[coveralls-image]: http://img.shields.io/coveralls/floatdrop/jsot-bh/master.svg\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffloatdrop%2Fjsot-bh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffloatdrop%2Fjsot-bh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffloatdrop%2Fjsot-bh/lists"}