dev-master
9999999-dev https://github.com/chris-ware/bem-twig-extension#READMETwig function that inserts static classes in BEM methodology.
MIT
The Requires
by Chris Ware
Wallogit.com
2017 © Pedro Peláez
Twig function that inserts static classes in BEM methodology.
Twig function that inserts static classes in BEM methodology., (*1)
Based on [https://github.com/drupal-pattern-lab/bem-twig-extension], but adapted to be available as a normal twig extension, (*2)
$twig = new Twig_Environment($loader, $options); $twig->addExtension(new Bem\Twig\BemExtension());
<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)
Twig function that inserts static classes in BEM methodology.
MIT