An open API service indexing awesome lists of open source software.

https://github.com/chris-ware/bem-twig-extension

BEM Twig Extension
https://github.com/chris-ware/bem-twig-extension

Last synced: 6 months ago
JSON representation

BEM Twig Extension

Awesome Lists containing this project

README

          

# bem-twig-extension
Twig function that inserts static classes in BEM methodology.

Based on [https://github.com/drupal-pattern-lab/bem-twig-extension], but adapted to be available as a normal twig extension

## Add Extension

```php
$twig = new Twig_Environment($loader, $options);
$twig->addExtension(new Bem\Twig\BemExtension());
```

## Usage (4 arguments)

#### Simple block name (required argument):
`

`

This creates:

`

`

#### Block with modifiers (optional array allowing multiple modifiers):
`

`

This creates:

`

`

#### Element with modifiers and blockname (optional):
`

`

This creates:

`

`

#### Element with blockname, but no modifiers (optional):

`

`

This creates:

`

`

#### Element with modifiers, blockname and extra classes (optional - in case you need non-BEM classes):

`

`

This creates:

`

`

#### Element with extra classes only (optional):

`

`

This creates:

`

`