Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/drupal-pattern-lab/add-attributes-twig-extension

add_attributes twig extension
https://github.com/drupal-pattern-lab/add-attributes-twig-extension

drupal drupal-8 pattern-lab twig

Last synced: about 1 month ago
JSON representation

add_attributes twig extension

Awesome Lists containing this project

README

        

# add-attributes-twig-extension

Twig function that allows addition of attributes that can be rendered in both Drupal and Pattern Lab. Merges with template level attributes in Drupal and prevents them from trickling down into includes.

## Usage
```
{% set additional_attributes = {
"class": ["foo", "bar"],
"baz": ["foobar", "goobar"],
"foobaz": "goobaz",
} %}


```

Can also be used with the [bem function](https://github.com/drupal-pattern-lab/bem-twig-extension):
```
{% set additional_attributes = {
"class": bem("foo", ["bar", "baz"], "foobar"),
} %}


```