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

https://github.com/timkelty/htmlattributes-craft

HTML Attributes Twig filter for Craft CMS
https://github.com/timkelty/htmlattributes-craft

Last synced: 10 months ago
JSON representation

HTML Attributes Twig filter for Craft CMS

Awesome Lists containing this project

README

          

# htmlAttributes

A Craft plugin (Twig filter) to help with the output of HTML attributes.

## Usage

### Twig template
```
{% set attrs = {
class: ['myClass', 'myClass2'],
style: {
'background-image': "url('img.png')",
'color': 'red',
},
'data-foo': {
someKey: 'foo',
otherKey: 'bar',
myArray: ['foo', 'bar', 'baz'],
},
'data-bar': true,
'data-baz': null,
'data-qux': false,
} %}


```

`htmlAttributes` is also aliased to `htmlAttrs` for convenince.

### Output
```


```