What is the standard method for adding classes in twig template?
I'm going straightly to the main subject point:
Scenario-1:
I have some classes and I want to collect them in a group and add this group to the existing group that added before:
I try below code but it seems that something is wrong.
{%
set classes = [
'block',
'block-' ~ configuration.provider|clean_class,
'block-' ~ plugin_id|clean_class,
]
%}
{%
set my-classes = [
'class-name-1',
'class-name-2',
'class-name-3',
'class-name-4',
]
%}
<div{{ attributes.addClass('classes my-classes') }}>
What tips should I consider for a class group name, For example, Is it important to follow PHP
variables name convention, Can I use hyphen character in class group names?
Scenario -2:
I have few classes names and I want to add theme straightly to default added classes, like below:
views-view-unformatted:
<div {{ row.attributes.addClass(row_classes 'class-name-1 class-name-2') }}>