Last active
March 17, 2019 03:33
-
-
Save yesthatdarya/8e56fa99df615f3e207a2a1b909b4e27 to your computer and use it in GitHub Desktop.
A new and improved field template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% | |
set classes = [ | |
'field', | |
'field--name-' ~ field_name|clean_class, | |
'field--type-' ~ field_type|clean_class, | |
'field--label-' ~ label_display, | |
] | |
%} | |
{% | |
set title_classes = [ | |
'field__label', | |
label_display == 'visually_hidden' ? 'visually-hidden', | |
] | |
%} | |
{% block field %} | |
<div{{ attributes.addClass(classes) }}> | |
{% block label %} | |
{% if label and not label_hidden %} | |
<div{{ title_attributes.addClass(title_classes) }}>{{ label }}</div> | |
{% endif %} | |
{% endblock %} | |
{% block content %} | |
{% if multiple %} | |
<div class="field__items"> | |
{% block items %} | |
{% for item in items %} | |
<div{{ item.attributes.addClass('field__item') }}>{{ item.content }}</div> | |
{% endfor %} | |
{% endblock %} | |
</div> | |
{% else %} | |
{{ block('items') }} | |
{% endif %} | |
{% endblock %} | |
</div> | |
{% endblock %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment