flag_list_flag.html.twig in Flag Lists 8
Same filename and directory in other branches
Default theme implementation for flag links.
Available variables:
- attributes: HTML attributes for the link element.
- title: The flag link title.
- action: 'flag' or 'unflag'
- flag: The flag object.
- flaggable: The flaggable entity.
- flagging_collection: The flagging_collection id.
File
templates/flag_list_flag.html.twigView source
- {#
- /**
- * @file
- * Default theme implementation for flag links.
- *
- * Available variables:
- * - attributes: HTML attributes for the link element.
- * - title: The flag link title.
- * - action: 'flag' or 'unflag'
- * - flag: The flag object.
- * - flaggable: The flaggable entity.
- * - flagging_collection: The flagging_collection id.
- */
- #}
- {% spaceless %}
- {# Depending on the flag action, set the appropriate action class. #}
- {% if action == 'unflag' %}
- {% set action_class = 'action-unflag' %}
- {% else %}
- {% set action_class = 'action-flag' %}
- {% endif %}
-
- {# Set the remaining Flag CSS classes. #}
- {% if flagging_collection %}
- {# Attach the flag lists CSS library.#}
- {{ attach_library('flag_lists/flag_lists.link') }}
- {% set classes = [
- 'flag',
- 'flag-lists',
- 'flag-' ~ flag.id()|clean_class,
- 'js-flag-' ~ flag.id()|clean_class ~ '-' ~ flaggable.id(),
- 'js-flag-' ~ flag.id()|clean_class ~ '-' ~ flaggable.id() ~
- '-' ~ flagging_collection,
- action_class
- ]
- %}
- {% else %}
- {# Attach the flag CSS library.#}
- {{ attach_library('flag/flag.link') }}
- {% set classes = [
- 'flag',
- 'flag-' ~ flag.id()|clean_class,
- 'js-flag-' ~ flag.id()|clean_class ~ '-' ~ flaggable.id(),
- action_class
- ]
- %}
- {% endif %}
-
- {# Set nofollow to prevent search bots from crawling anonymous flag links #}
- {% set attributes = attributes.setAttribute('rel', 'nofollow') %}
-
- <div class="{{classes|join(' ')}}"><a{{ attributes }}>{{ title }}</a></div>
- {% endspaceless %}