Skip to content

Tweak the TOC Tree templates #66

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Templates/default/html/toc-item.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

{% if tocItem.children|length %}
{% include "toc-level.html.twig" with {
tocItems:tocItem.children
tocItems: tocItem.children,
toc_deep_level: toc_deep_level + 1
} %}
{% endif %}
</li>
4 changes: 2 additions & 2 deletions src/Templates/default/html/toc-level.html.twig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% apply spaceless %}
<ul>
<ul class="toctree toctree-level-{{ toc_deep_level ?? 1 }} toctree-length-{{ tocItems|length }}">
{% for tocItem in tocItems %}
{% include "toc-item.html.twig" %}
{% include "toc-item.html.twig" with { toc_deep_level: 1 } %}
{% endfor %}
</ul>
{% endapply %}
2 changes: 1 addition & 1 deletion src/Templates/default/html/toc.html.twig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% apply spaceless %}
<div class="toctree-wrapper compound">
<div class="toctree-wrapper">
{% include "toc-level.html.twig" %}
</div>
{% endapply %}
4 changes: 2 additions & 2 deletions tests/fixtures/expected/build-pdf/book.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<h1 id="book-index-book">Book</h1>
<img src="_images/symfony-logo.png">
<p>Here is a link to the <a href="#index" class="reference internal">main index</a></p>
<div class="toctree-wrapper compound">
<ul>
<div class="toctree-wrapper">
<ul class="toctree toctree-level-1 toctree-length-2">
<li><a href="https://symfony.com/doc/4.0/book/first-page.html#first-page">First page</a></li>
<li><a href="https://symfony.com/doc/4.0/book/second-page.html#second-page">Second page</a></li>
</ul>
Expand Down
6 changes: 3 additions & 3 deletions tests/fixtures/expected/main/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ <h1 id="some-test-docs">
<a class="headerlink" href="#some-test-docs" title="Permalink to this headline">Some Test Docs!</a>
</h1>
<img src="_images/symfony-logo.png" />
<div class="toctree-wrapper compound">
<ul>
<div class="toctree-wrapper">
<ul class="toctree toctree-level-1 toctree-length-2">
<li><a href="datetime.html#datetimetype-field">DateTimeType Field</a>
<ul>
<ul class="toctree toctree-level-2 toctree-length-4">
<li><a href="datetime.html#field-options">Field Options</a></li>
<li><a href="datetime.html#overridden-options">Overridden Options</a></li>
<li><a href="datetime.html#field-variables">Field Variables</a></li>
Expand Down
26 changes: 13 additions & 13 deletions tests/fixtures/expected/toctree/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,40 @@
<body>
<div class="section">
<h1 id="toctree"><a class="headerlink" href="#toctree" title="Permalink to this headline">Toctree</a></h1>
<div class="toctree-wrapper compound">
<ul>
<div class="toctree-wrapper">
<ul class="toctree toctree-level-1 toctree-length-1">
<li><a href="file.html#title">Title</a>
<ul>
<ul class="toctree toctree-level-2 toctree-length-1">
<li><a href="file.html#sub-title">Sub title</a></li>
</ul>
</li>
</ul>
</div>
<div class="toctree-wrapper compound">
<ul>
<div class="toctree-wrapper">
<ul class="toctree toctree-level-1 toctree-length-1">
<li><a href="file.html#title">Title</a></li>
</ul>
</div>
<div class="toctree-wrapper compound">
<ul>
<div class="toctree-wrapper">
<ul class="toctree toctree-level-1 toctree-length-1">
<li><a href="directory/another_file.html#another-file">Another file</a></li>
</ul>
</div>
<div class="toctree-wrapper compound">
<ul>
<div class="toctree-wrapper">
<ul class="toctree toctree-level-1 toctree-length-3">
<li><a href="index.html#toctree">Toctree</a></li>
<li><a href="directory/another_file.html#another-file">Another file</a></li>
<li><a href="file.html#title">Title</a>
<ul>
<ul class="toctree toctree-level-2 toctree-length-1">
<li><a href="file.html#sub-title">Sub title</a></li>
</ul>
</li>
</ul>
</div>
<div class="toctree-wrapper compound">
<ul>
<div class="toctree-wrapper">
<ul class="toctree toctree-level-1 toctree-length-3">
<li><a href="file.html#title">Title</a>
<ul>
<ul class="toctree toctree-level-2 toctree-length-1">
<li><a href="file.html#sub-title">Sub title</a></li>
</ul>
</li>
Expand Down