"Fossies" - the Fresh Open Source Software Archive

Member "drupal-8.9.10/core/themes/bartik/templates/classy/navigation/book-tree.html.twig" (26 Nov 2020, 1675 Bytes) of package /linux/www/drupal-8.9.10.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) HTML source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 {#
    2 /**
    3  * @file
    4  * Theme override to display a book tree.
    5  *
    6  * Returns HTML for a wrapper for a book sub-tree.
    7  *
    8  * Available variables:
    9  * - items: A nested list of book items. Each book item contains:
   10  *   - attributes: HTML attributes for the book item.
   11  *   - below: The book item child items.
   12  *   - title: The book link title.
   13  *   - url: The book link URL, instance of \Drupal\Core\Url.
   14  *   - is_expanded: TRUE if the link has visible children within the current
   15  *     book tree.
   16  *   - is_collapsed: TRUE if the link has children within the current book tree
   17  *     that are not currently visible.
   18  *   - in_active_trail: TRUE if the link is in the active trail.
   19  */
   20 #}
   21 {% import _self as book_tree %}
   22 
   23 {#
   24   We call a macro which calls itself to render the full tree.
   25   @see https://twig.symfony.com/doc/1.x/tags/macro.html
   26 #}
   27 {{ book_tree.book_links(items, attributes, 0) }}
   28 
   29 {% macro book_links(items, attributes, menu_level) %}
   30   {% import _self as book_tree %}
   31   {% if items %}
   32     {% if menu_level == 0 %}
   33       <ul{{ attributes.addClass('menu') }}>
   34     {% else %}
   35       <ul class="menu">
   36     {% endif %}
   37     {% for item in items %}
   38       {%
   39         set classes = [
   40           'menu-item',
   41           item.is_expanded ? 'menu-item--expanded',
   42           item.is_collapsed ? 'menu-item--collapsed',
   43           item.in_active_trail ? 'menu-item--active-trail',
   44         ]
   45       %}
   46       <li{{ item.attributes.addClass(classes) }}>
   47         {{ link(item.title, item.url) }}
   48         {% if item.below %}
   49           {{ book_tree.book_links(item.below, attributes, menu_level + 1) }}
   50         {% endif %}
   51       </li>
   52     {% endfor %}
   53     </ul>
   54   {% endif %}
   55 {% endmacro %}