You are here

item-list--dropdown.html.twig in Express 8

Theme override for an item list.

Available variables:

  • alignment: (optional) The alignment of the dropdown menu.
  • items: A list of items. Each item contains:
    • attributes: HTML attributes to be applied to each list item.
    • value: The content of the list element.
  • title: The title of the list.
  • list_type: The tag for list element ("ul" or "ol").
  • wrapper_attributes: HTML attributes to be applied to the list wrapper.
  • attributes: HTML attributes to be applied to the list.
  • empty: A message to display when there are no items. Allowed value is a string or render array.
  • context: A list of contextual data associated with the list. May contain:
    • list_style: The custom list style.

File

themes/contrib/bootstrap/templates/bootstrap/item-list--dropdown.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Theme override for an item list.
  5. *
  6. * Available variables:
  7. * - alignment: (optional) The alignment of the dropdown menu.
  8. * - items: A list of items. Each item contains:
  9. * - attributes: HTML attributes to be applied to each list item.
  10. * - value: The content of the list element.
  11. * - title: The title of the list.
  12. * - list_type: The tag for list element ("ul" or "ol").
  13. * - wrapper_attributes: HTML attributes to be applied to the list wrapper.
  14. * - attributes: HTML attributes to be applied to the list.
  15. * - empty: A message to display when there are no items. Allowed value is a
  16. * string or render array.
  17. * - context: A list of contextual data associated with the list. May contain:
  18. * - list_style: The custom list style.
  19. *
  20. * @ingroup templates
  21. *
  22. * @see template_preprocess_item_list()
  23. */
  24. #}
  25. {%
  26. set classes = [
  27. 'dropdown-menu',
  28. alignment == 'left' ? 'dropdown-menu-left',
  29. alignment == 'right' ? 'dropdown-menu-right',
  30. ]
  31. %}
  32. {% if items or empty -%}
  33. {%- if items -%}
  34. <{{ list_type }}{{ attributes.addClass(classes) }} role="menu">
  35. {%- for item in items -%}
  36. <li{{ item.attributes }}>{{ item.value }}</li>
  37. {%- endfor -%}
  38. </{{ list_type }}>
  39. {%- else -%}
  40. {{- empty -}}
  41. {%- endif -%}
  42. {%- endif %}