Skip to content

Instantly share code, notes, and snippets.

@achraf-jeday
Created November 29, 2018 14:53
Show Gist options
  • Save achraf-jeday/fa8c326eb659a8cbfa3d12aa61ac5a02 to your computer and use it in GitHub Desktop.
Save achraf-jeday/fa8c326eb659a8cbfa3d12aa61ac5a02 to your computer and use it in GitHub Desktop.
TWIG Add classes to attributes array
attributes.addClass()
Adds classes or merges them on to array of existing CSS classes.
Single class:
<div{{ attributes.addClass('my-class') }}></div>
Multiple classes:
{%
set classes = [
'red',
'green',
]
%}
<div{{ attributes.addClass(classes) }}></div>
@achraf-jeday
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment