Twig function that inserts static classes into Pattern Lab and adds them to the Attributes object in Drupal
Twig function that inserts static classes into Pattern Lab and adds them to the Attributes object in Drupal, (*1)
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., (*2)
<h1 {{ bem('title') }}>
, (*3)
This creates:, (*4)
<h1 class="title">
, (*5)
<h1 {{ bem('title', ['small', 'red']) }}>
, (*6)
This creates:, (*7)
<h1 class="title title--small title--red">
, (*8)
<h1 {{ bem('title', ['small', 'red'], 'card') }}>
, (*9)
This creates:, (*10)
<h1 class="card__title card__title--small card__title--red">
, (*11)
<h1 {{ bem('title', '', 'card') }}>
, (*12)
This creates:, (*13)
<h1 class="card__title">
, (*14)
<h1 {{ bem('title', ['small', 'red'], 'card', ['js-click', 'something-else']) }}>
, (*15)
This creates:, (*16)
<h1 class="card__title card__title--small card__title--red js-click something-else">
, (*17)
<h1 {{ bem('title', '', '', ['js-click']) }}>
, (*18)
This creates:, (*19)
<h1 class="title js-click">
, (*20)