Document conditional TOC rendering (#1376)
* Document conditional TOC rendering * Simplify demonstration of conditional rendering
This commit is contained in:
parent
8630c790b8
commit
d29693066e
|
@ -12,8 +12,9 @@ documentation for information on its structure.
|
||||||
Here is an example of using that field to render a two-level table of contents:
|
Here is an example of using that field to render a two-level table of contents:
|
||||||
|
|
||||||
```jinja2
|
```jinja2
|
||||||
<ul>
|
{% if page.toc %}
|
||||||
{% for h1 in page.toc %}
|
<ul>
|
||||||
|
{% for h1 in page.toc %}
|
||||||
<li>
|
<li>
|
||||||
<a href="{{h1.permalink | safe}}">{{ h1.title }}</a>
|
<a href="{{h1.permalink | safe}}">{{ h1.title }}</a>
|
||||||
{% if h1.children %}
|
{% if h1.children %}
|
||||||
|
@ -26,8 +27,9 @@ Here is an example of using that field to render a two-level table of contents:
|
||||||
</ul>
|
</ul>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
{% endif %}
|
||||||
```
|
```
|
||||||
|
|
||||||
While headers are neatly ordered in this example, it will work just as well with disjoint headers.
|
While headers are neatly ordered in this example, it will work just as well with disjoint headers.
|
||||||
|
|
Loading…
Reference in a new issue