Ecosyste.ms: Awesome

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

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: 27 days ago
JSON representation

add_attributes twig extension

Lists

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"),
} %}


```