Skip to content

Instantly share code, notes, and snippets.

@jacine
Last active May 2, 2016 20:29
Show Gist options
  • Save jacine/7503092d6a09a5100c6122643d936f20 to your computer and use it in GitHub Desktop.
Save jacine/7503092d6a09a5100c6122643d936f20 to your computer and use it in GitHub Desktop.
Component
{# Core Classes #}
{%
set classes = [
has_parent ? 'js-form-wrapper',
has_parent ? 'form-wrapper',
]
%}
{# Map #type to theme component #}
{%
set map = {
'more_link': 'btn',
}
%}
{% set remove_classes = [] %}
{% set add_classes = [] %}
{% for key,value in map %}
{# Prefer component classes instead of defaults when a match is present, e.g.
- Add: .btn btn--more-link
- Remove: .more-link
#}
{% if element['#type'] == key %}
{# Add component classes. #}
{% set add_classes = [
value,
value ~ '--' ~ key|clean_class,
] %}
{# Remove the original base #type class. #}
{% set remove_classes = [ key|clean_class ] %}
{% endif %}
{% endfor %}
{% block content %}
{% endblock %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment