Download the PHP package drupal-pattern-lab/bem-twig-extension without Composer
On this page you can find all versions of the php package drupal-pattern-lab/bem-twig-extension. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download drupal-pattern-lab/bem-twig-extension
More information about drupal-pattern-lab/bem-twig-extension
Files in drupal-pattern-lab/bem-twig-extension
Package bem-twig-extension
Short Description Twig function that inserts static classes into Pattern Lab and adds them to the Attributes object in Drupal
License MIT
Informations about the package bem-twig-extension
bem-twig-extension
Twig function that inserts static classes into Pattern Lab and adds them to the Attributes object in Drupal
Requirements
To 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 module can be helpful for that.
Usage (4 arguments)
Simple block name (required argument):
<h1 {{ bem('title') }}>
This creates:
<h1 class="title">
Block with modifiers (optional array allowing multiple modifiers):
<h1 {{ bem('title', ['small', 'red']) }}>
This creates:
<h1 class="title title--small title--red">
Element with modifiers and blockname (optional):
<h1 {{ bem('title', ['small', 'red'], 'card') }}>
This creates:
<h1 class="card__title card__title--small card__title--red">
Element with blockname, but no modifiers (optional):
<h1 {{ bem('title', '', 'card') }}>
This creates:
<h1 class="card__title">
Element with modifiers, blockname and extra classes (optional - in case you need non-BEM classes):
<h1 {{ bem('title', ['small', 'red'], 'card', ['js-click', 'something-else']) }}>
This creates:
<h1 class="card__title card__title--small card__title--red js-click something-else">
Element with extra classes only (optional):
<h1 {{ bem('title', '', '', ['js-click']) }}>
This creates:
<h1 class="title js-click">