You are here

toc-menu.html.twig in TOC API 8

Default theme implementation to display a table of contents as a select menu.

Returns HTML for a Table of contents select menu.

Available variables:

  • index: List of header items. Each header item contains:

    • prefix: The header option prefix. Either indentation or the complete path.
    • title: The header title.
    • url: The header fragrment (ie hash) URL, instance of \Drupal\Core\Url.

File

templates/toc-menu.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Default theme implementation to display a table of contents as a select menu.
  5. *
  6. * Returns HTML for a Table of contents select menu.
  7. *
  8. * Available variables:
  9. * - index: List of header items. Each header item contains:
  10. * - prefix: The header option prefix. Either indentation or the complete path.
  11. * - title: The header title.
  12. * - url: The header fragrment (ie hash) URL, instance of \Drupal\Core\Url.
  13. *
  14. * @ingroup themeable
  15. */
  16. #}
  17. {% set classes = ['toc', 'toc-menu'] %}
  18. <form {{ attributes.addClass(classes) }}>
  19. <select>
  20. <option value="">{{ title }}</option>
  21. {% for item in index %}
  22. <option value="{{ item.url }}">{{ item.prefix }}{{ item.title }}</option>
  23. {% endfor %}
  24. </select>
  25. </form>