drupal-pattern-lab / add-attributes-twig-extension
允许在 Drupal 和 Pattern Lab 中渲染的属性添加的 Twig 函数
v1.0.1
2017-08-17 03:05 UTC
This package is auto-updated.
Last update: 2024-09-15 06:50:29 UTC
README
允许在 Drupal 和 Pattern Lab 中渲染的属性添加的 Twig 函数。与 Drupal 模板级别的属性合并,并防止它们渗透到包含文件中。
使用方法
{% set additional_attributes = {
"class": ["foo", "bar"],
"baz": ["foobar", "goobar"],
"foobaz": "goobaz",
} %}
<div {{ add_attributes(additional_attributes) }}></div>
也可以与 bem 函数 一起使用
{% set additional_attributes = {
"class": bem("foo", ["bar", "baz"], "foobar"),
} %}
<div {{ add_attributes(additional_attributes) }}></div>