{"id":13513346,"url":"https://github.com/drupal-pattern-lab/bem-twig-extension","last_synced_at":"2026-01-11T16:46:18.476Z","repository":{"id":56972626,"uuid":"97155070","full_name":"drupal-pattern-lab/bem-twig-extension","owner":"drupal-pattern-lab","description":"Twig function that inserts static classes into Pattern Lab but adds them to attributes in Drupal","archived":false,"fork":false,"pushed_at":"2019-11-21T17:43:40.000Z","size":15,"stargazers_count":14,"open_issues_count":7,"forks_count":7,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-08T14:16:20.854Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/drupal-pattern-lab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-13T18:50:50.000Z","updated_at":"2021-09-24T18:52:00.000Z","dependencies_parsed_at":"2022-08-21T10:20:16.207Z","dependency_job_id":null,"html_url":"https://github.com/drupal-pattern-lab/bem-twig-extension","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drupal-pattern-lab%2Fbem-twig-extension","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drupal-pattern-lab%2Fbem-twig-extension/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drupal-pattern-lab%2Fbem-twig-extension/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drupal-pattern-lab%2Fbem-twig-extension/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/drupal-pattern-lab","download_url":"https://codeload.github.com/drupal-pattern-lab/bem-twig-extension/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246403961,"owners_count":20771526,"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-08-01T04:00:53.261Z","updated_at":"2026-01-11T16:46:18.451Z","avatar_url":"https://github.com/drupal-pattern-lab.png","language":"PHP","funding_links":[],"categories":["External tools"],"sub_categories":["Pattern Lab"],"readme":"# bem-twig-extension\nTwig function that inserts static classes into Pattern Lab and adds them to the Attributes object in Drupal\n\n## Requirements\n\nTo use in Pattern Lab, simply place in the `_twig-components/functions` directory. Drupal needs to recognize the Twig function, so something like [Unified Twig Extensions](https://github.com/drupal-pattern-lab/unified-twig-extensions/) module can be helpful for that.\n\n## Usage (4 arguments)\n\n#### Simple block name (required argument):\n`\u003ch1 {{ bem('title') }}\u003e`\n\nThis creates:\n\n`\u003ch1 class=\"title\"\u003e`\n\n#### Block with modifiers (optional array allowing multiple modifiers):\n`\u003ch1 {{ bem('title', ['small', 'red']) }}\u003e`\n\nThis creates:\n\n`\u003ch1 class=\"title title--small title--red\"\u003e`\n\n#### Element with modifiers and blockname (optional):\n`\u003ch1 {{ bem('title', ['small', 'red'], 'card') }}\u003e`\n\nThis creates:\n\n`\u003ch1 class=\"card__title card__title--small card__title--red\"\u003e`\n\n#### Element with blockname, but no modifiers (optional):\n\n`\u003ch1 {{ bem('title', '', 'card') }}\u003e`\n\nThis creates:\n\n`\u003ch1 class=\"card__title\"\u003e`\n\n#### Element with modifiers, blockname and extra classes (optional - in case you need non-BEM classes):\n\n`\u003ch1 {{ bem('title', ['small', 'red'], 'card', ['js-click', 'something-else']) }}\u003e`\n\nThis creates:\n\n`\u003ch1 class=\"card__title card__title--small card__title--red js-click something-else\"\u003e`\n\n#### Element with extra classes only (optional):\n\n`\u003ch1 {{ bem('title', '', '', ['js-click']) }}\u003e`\n\nThis creates:\n\n`\u003ch1 class=\"title js-click\"\u003e`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrupal-pattern-lab%2Fbem-twig-extension","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdrupal-pattern-lab%2Fbem-twig-extension","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrupal-pattern-lab%2Fbem-twig-extension/lists"}