{# LIBRARIES #}
{{ attach_library('ui_patterns/tm_bits_tags.tm_bits_tags_lib') }}

{# VARIABLES #}
{% set global_icon_tag = global_icon_tag|default("fas fa-tag") %}
{% set list_class = list_class|default("") %}
{% set inverted = inverted|default(false) %}

{# TEMPLATE #}
{% if tags %}
  <ul class="ulc lb-tags {{ list_class }}">
    {% for tag in tags %}
      <li class="liin">
        {% set tag_url = (not_links ? false : tag.url) %}

        {% set link_classes = [
          "tag tc-" ~ tag.color,
          not_links ? 'nl',
          inverted ? 'tags-invert',
        ] %}

        {% set attr = tag.attr|default(create_attribute()) %}
        {% include "@atoms/tm-links/icon-bookended/icon-bookended.twig" with {
          "text": tag.name,
          "url": tag_url,
          "icon_left": global_icon_tag,
          "class": link_classes|join(' '),
          "attr": attr,
        } only %}
      </li>
    {% endfor %}
  </ul>
{% endif %}
