You are here

flag.html.twig in Open Social 8.8

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.

File

themes/socialbase/templates/field/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. */
  13. #}
  14. {% spaceless %}
  15. {# Depending on the flag action, set the appropriate action class. #}
  16. {% if action == 'unflag' %}
  17. {% set action_class = 'action-unflag' %}
  18. {% else %}
  19. {% set action_class = 'action-flag' %}
  20. {% endif %}
  21. {# Set the remaining Flag CSS classes. #}
  22. {% set classes = [
  23. 'btn',
  24. 'btn-default',
  25. 'btn-sm',
  26. 'btn-follow',
  27. 'flag',
  28. 'flag-' ~ flag.id()|clean_class,
  29. 'js-flag-' ~ flag.id()|clean_class ~ '-' ~ flaggable.id(),
  30. action_class
  31. ] %}
  32. {% set attributes = attributes.addClass(classes) %}
  33. <a role="button"{{ attributes }}>{{ title }}</a>
  34. {% endspaceless %}