{"id":21206587,"url":"https://github.com/oncomouse/middleman-bem-html","last_synced_at":"2025-03-14T23:14:09.806Z","repository":{"id":56893487,"uuid":"62458962","full_name":"oncomouse/middleman-bem-html","owner":"oncomouse","description":null,"archived":false,"fork":false,"pushed_at":"2016-07-02T16:07:40.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-21T15:48:37.140Z","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:05:47.000Z","updated_at":"2016-07-02T16:06:06.000Z","dependencies_parsed_at":"2022-08-20T16:10:38.283Z","dependency_job_id":null,"html_url":"https://github.com/oncomouse/middleman-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%2Fmiddleman-bem-html","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oncomouse%2Fmiddleman-bem-html/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oncomouse%2Fmiddleman-bem-html/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oncomouse%2Fmiddleman-bem-html/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oncomouse","download_url":"https://codeload.github.com/oncomouse/middleman-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.570Z","updated_at":"2025-03-14T23:14:09.787Z","avatar_url":"https://github.com/oncomouse.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# middleman-bem-html\n\nA Middleman extension to add BEM classes to HTML based on HTML attributes. \n\nMakes use of [bem_html](https://github.com/oncomouse/bem_html) to handle class generation and [css_dead_class](https://github.com/oncomouse/css_dead_class) to cleanup unused CSS classes.\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\nAdd\n\n~~~\ngem \"middleman-bem-html\"\n~~~\n\nto your `Gemfile` and run `bundle update`\n\n## Configuration\n\nIn `config.rb`, add the following:\n\n~~~ruby\nactivate :bem_html\n\nconfig[:classes_to_keep] = [\n\t'no-js',\n]\nconfig[:internal_css] = true\n~~~\n\nThe two configuration options are:\n\n### `:classes_to_keep`\n\nAn array of CSS class names to not remove, even if they are not present in any of the CSS files.\n\n### `:internal_css`\n\n**defaults to `true`**\n\nIf you are using any `external_pipeline` calls to configure your CSS files (like gulp or PostCSS), the `after_build` method that this extension uses to remove all the unused CSS from production HTML will run before the CSS has been generated (as `external_pipeline` calls always run *after* extension methods), as such you *must* use an `external_pipeline` to remove the unused CSS classes this extension may generate.\n\nIf this effects you, please consider using [postcss-deadclass](https://github.com/oncomouse/postcss-deadclass) to remove the unused CSS classes using PostCSS.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foncomouse%2Fmiddleman-bem-html","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foncomouse%2Fmiddleman-bem-html","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foncomouse%2Fmiddleman-bem-html/lists"}