summaryrefslogtreecommitdiffstats
path: root/core/themes/classy/templates/navigation/book-tree.html.twig
diff options
context:
space:
mode:
Diffstat (limited to 'core/themes/classy/templates/navigation/book-tree.html.twig')
-rw-r--r--core/themes/classy/templates/navigation/book-tree.html.twig38
1 files changed, 33 insertions, 5 deletions
diff --git a/core/themes/classy/templates/navigation/book-tree.html.twig b/core/themes/classy/templates/navigation/book-tree.html.twig
index be69457..543696c 100644
--- a/core/themes/classy/templates/navigation/book-tree.html.twig
+++ b/core/themes/classy/templates/navigation/book-tree.html.twig
@@ -1,14 +1,42 @@
{#
/**
* @file
- * Theme override for a book tree.
+ * Theme override to display a book tree.
*
* Returns HTML for a wrapper for a book sub-tree.
*
* Available variables:
- * - tree: An HTML string containing the tree's items.
- *
- * @see template_preprocess_book_tree()
+ * - items: A nested list of book items. Each book item contains:
+ * - attributes: HTML attributes for the book item.
+ * - below: The book item child items.
+ * - title: The book link title.
+ * - url: The book link URL, instance of \Drupal\Core\Url.
*/
#}
-<ul class="menu">{{ tree }}</ul>
+{% import _self as book_tree %}
+
+{#
+ We call a macro which calls itself to render the full tree.
+ @see http://twig.sensiolabs.org/doc/tags/macro.html
+#}
+{{ book_tree.book_links(items, attributes, 0) }}
+
+{% macro book_links(items, attributes, menu_level) %}
+ {% import _self as book_tree %}
+ {% if items %}
+ {% if menu_level == 0 %}
+ <ul{{ attributes.addClass('menu') }}>
+ {% else %}
+ <ul class="menu">
+ {% endif %}
+ {% for item in items %}
+ <li{{ item.attributes }}>
+ {{ link(item.title, item.url) }}
+ {% if item.below %}
+ {{ book_tree.book_links(item.below, attributes, menu_level + 1) }}
+ {% endif %}
+ </li>
+ {% endfor %}
+ </ul>
+ {% endif %}
+{% endmacro %}