You are here

flag_list_flag.html.twig in Flag Lists 8

Same filename and directory in other branches
  1. 4.0.x templates/flag_list_flag.html.twig

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.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Default theme implementation for flag links.
  5. *
  6. * Available variables:
  7. * - attributes: HTML attributes for the link element.
  8. * - title: The flag link title.
  9. * - action: 'flag' or 'unflag'
  10. * - flag: The flag object.
  11. * - flaggable: The flaggable entity.
  12. * - flagging_collection: The flagging_collection id.
  13. */
  14. #}
  15. {% spaceless %}
  16. {# Depending on the flag action, set the appropriate action class. #}
  17. {% if action == 'unflag' %}
  18. {% set action_class = 'action-unflag' %}
  19. {% else %}
  20. {% set action_class = 'action-flag' %}
  21. {% endif %}
  22. {# Set the remaining Flag CSS classes. #}
  23. {% if flagging_collection %}
  24. {# Attach the flag lists CSS library.#}
  25. {{ attach_library('flag_lists/flag_lists.link') }}
  26. {% set classes = [
  27. 'flag',
  28. 'flag-lists',
  29. 'flag-' ~ flag.id()|clean_class,
  30. 'js-flag-' ~ flag.id()|clean_class ~ '-' ~ flaggable.id(),
  31. 'js-flag-' ~ flag.id()|clean_class ~ '-' ~ flaggable.id() ~
  32. '-' ~ flagging_collection,
  33. action_class
  34. ]
  35. %}
  36. {% else %}
  37. {# Attach the flag CSS library.#}
  38. {{ attach_library('flag/flag.link') }}
  39. {% set classes = [
  40. 'flag',
  41. 'flag-' ~ flag.id()|clean_class,
  42. 'js-flag-' ~ flag.id()|clean_class ~ '-' ~ flaggable.id(),
  43. action_class
  44. ]
  45. %}
  46. {% endif %}
  47. {# Set nofollow to prevent search bots from crawling anonymous flag links #}
  48. {% set attributes = attributes.setAttribute('rel', 'nofollow') %}
  49. <div class="{{classes|join(' ')}}"><a{{ attributes }}>{{ title }}</a></div>
  50. {% endspaceless %}