{"id":21206585,"url":"https://github.com/oncomouse/bem_html","last_synced_at":"2025-03-14T23:14:09.935Z","repository":{"id":62554100,"uuid":"62459054","full_name":"oncomouse/bem_html","owner":"oncomouse","description":null,"archived":false,"fork":false,"pushed_at":"2016-07-05T14:31:35.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-21T15:48:35.631Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","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/oncomouse.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":"2016-07-02T16:07:59.000Z","updated_at":"2016-07-02T16:12:08.000Z","dependencies_parsed_at":"2022-11-03T04:45:48.400Z","dependency_job_id":null,"html_url":"https://github.com/oncomouse/bem_html","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oncomouse%2Fbem_html","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oncomouse%2Fbem_html/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oncomouse%2Fbem_html/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oncomouse%2Fbem_html/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oncomouse","download_url":"https://codeload.github.com/oncomouse/bem_html/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243658270,"owners_count":20326467,"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-11-20T20:56:09.504Z","updated_at":"2025-03-14T23:14:09.912Z","avatar_url":"https://github.com/oncomouse.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bem_html\n\nBEM helpers for HTML.\n\nUtility to convert HTML attributes (`bem-block`, `bem-element`, and `bem-modifiers`) to proper CSS classnames for use in BEM.\n\n## Purpose\n\nIn large projects, BEM namespacing can get fairly complicated. In Sass and PostCSS, there exist a number of helper methods to simply the creation of nested Block, Element, Modifier classes; however, this plugin provides similar helper methods within HTML itself.\n\n## Sample Usage\n\nSay you had a BEM block called \"widget\" that had the following structure in HTML:\n\n~~~html\n\n\u003cdiv class=\"widget\"\u003e\n\t\u003ch1 class=\"widget__heading widget__heading--lime\"\u003eHeading\u003c/h1\u003e\n\t\u003csection class=\"widget__content\"\u003e\n\t\t\u003cp class=\"widget__content__first-paragraph\"\u003eFirst Paragraph\u003c/p\u003e\n\t\u003c/section\u003e\n\u003c/div\u003e\n~~~\n\nWith bem-html, you could define that structure instead as the following:\n\n~~~html\n\u003cdiv bem-block=\"widget\"\u003e\n\t\u003ch1 bem-element=\"heading\" modifiers=\"[:lime]\"\u003eHeading\u003c/h1\u003e\n\t\u003csection bem-element=\"content\"\u003e\n\t\t\u003cp bem-element=\"first-paragraph\"\u003eFirst Paragraph\u003c/p\u003e\n\t\u003c/section\u003e\n\u003c/div\u003e\n~~~\n\nAnd this extension would produce the desired HTML.\n\nOriginally, this extension was specifically designed for HAML, where it really shines:\n\n~~~haml\n%div{bem:{block: :widget}}\n\t%h1{bem:{element: :heading, modifiers: [:lime]}} Heading\n\t%section{bem:{element: :content}}\n\t\t%p{bem: {element: \"first-paragraph\"}} First Paragraph\n~~~\n\n## Installation\n\nInstall using `gem bem_html`\n\n## Usage\n\nSample Ruby code:\n\n~~~ ruby\nrequire \"bem_html\"\n\nhtml = IO.read(\"index.html\")\nBemHtml.parse(html) # -\u003e Will output index.html with bem-* tags converted to CSS names\n~~~\n\n## Todo\n\n* Binary parser for CLI usage","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foncomouse%2Fbem_html","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foncomouse%2Fbem_html","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foncomouse%2Fbem_html/lists"}