2017 © Pedro Peláez
 

library bem-twig-extension

Twig function that inserts static classes into Pattern Lab and adds them to the Attributes object in Drupal

image

drupal-pattern-lab/bem-twig-extension

Twig function that inserts static classes into Pattern Lab and adds them to the Attributes object in Drupal

  • Thursday, August 17, 2017
  • by ModulesUnraveled
  • Repository
  • 1 Watchers
  • 6 Stars
  • 18,002 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 2 Open issues
  • 2 Versions
  • 54 % Grown

The README.md

bem-twig-extension

Twig function that inserts static classes into Pattern Lab and adds them to the Attributes object in Drupal, (*1)

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., (*2)

Usage (4 arguments)

Simple block name (required argument):

<h1 {{ bem('title') }}>, (*3)

This creates:, (*4)

<h1 class="title">, (*5)

Block with modifiers (optional array allowing multiple modifiers):

<h1 {{ bem('title', ['small', 'red']) }}>, (*6)

This creates:, (*7)

<h1 class="title title--small title--red">, (*8)

Element with modifiers and blockname (optional):

<h1 {{ bem('title', ['small', 'red'], 'card') }}>, (*9)

This creates:, (*10)

<h1 class="card__title card__title--small card__title--red">, (*11)

Element with blockname, but no modifiers (optional):

<h1 {{ bem('title', '', 'card') }}>, (*12)

This creates:, (*13)

<h1 class="card__title">, (*14)

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']) }}>, (*15)

This creates:, (*16)

<h1 class="card__title card__title--small card__title--red js-click something-else">, (*17)

Element with extra classes only (optional):

<h1 {{ bem('title', '', '', ['js-click']) }}>, (*18)

This creates:, (*19)

<h1 class="title js-click">, (*20)

The Versions

17/08 2017

dev-master

9999999-dev

Twig function that inserts static classes into Pattern Lab and adds them to the Attributes object in Drupal

  Sources   Download

MIT

by Evan Willhite
by Jeff Tomlinson

17/08 2017

v1.0.1

1.0.1.0

Twig function that inserts static classes into Pattern Lab and adds them to the Attributes object in Drupal

  Sources   Download

MIT

by Evan Willhite
by Jeff Tomlinson