I have created a twig template and have added classes like below.
{%
set title-classes = [
'title',
'h1',
]
%}
{%
set subtitle-classes = [
'subtitle',
'h2',
]
%}
<div{{ attributes.addClass('title-classes') }}>
{{ content.title }}
</div>
<div{{ attributes.addClass('subtitle-classes') }}>
{{ content.field_subtitle }}
</div>
What do I do when I have a complex HTML template. Consider the below. This is a very small section of my node type. Should I create classes for all of the different classes I use? Or can I just put them as I have below?
<div class="section highlighted">
<div class="title h1">
{{ content.title }}
</div>
<div class="subtitle h2">
{{ content.field_subtitle }}
</div>
<div class="panel intro padding-lg">
<p>{{ content.field_intro }}</p>
<p class="disclaimer">{{ content.field_intro_disclaimer }}</p>
<a href="{{ content.field_link }}" class="btn inline padding-lg hide-small">{{ content.field_link_text }}</a>
<a href="{{ content.field_link_2 }}" class="btn block hide-large hide-medium">{{ content.field_link_text_2 }}</a>
</div>
</div>
Whats the best way to create twig templates that use lots of different classes/attributes? Thanks