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
- Host: GitHub
- URL: https://github.com/chris-ware/bem-twig-extension
- Owner: chris-ware
- Created: 2018-01-02T11:34:31.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-02T11:51:29.000Z (over 8 years ago)
- Last Synced: 2025-11-27T14:47:24.437Z (8 months ago)
- Language: PHP
- Size: 1.95 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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:
`
`