drupal-pattern-lab/add-attributes-twig-extension

Twig function that allows addition of attributes that can be rendered in both Drupal and Pattern Lab

Maintainers

Package info

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

pkg:composer/drupal-pattern-lab/add-attributes-twig-extension

Statistics

Installs: 424 060

Dependents: 2

Suggesters: 0

Stars: 8

Open Issues: 6

v1.0.1 2017-08-17 03:05 UTC

This package is auto-updated.

Last update: 2026-02-15 10:11:46 UTC


README

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

<div {{ add_attributes(additional_attributes) }}></div>

Can also be used with the bem function:

{% set additional_attributes = {
  "class": bem("foo", ["bar", "baz"], "foobar"),
} %}

<div {{ add_attributes(additional_attributes) }}></div>