TOC Twig Filter
10 sites
Security covered
Drupal 10–11
This project provides a Twig filter that integrates with the TOC API to render tables of contents. It allows you to automatically generate and display a table of contents based on the content's headings, with options to customize the depth of headers included.
Twig filter rendering tables of contents via TOC API.
Usage
{% set body = content.body|render|toc %}
{{ body.toc }}
{{ body.content }}
{# OR #}
{% set body = content.body|render|toc('full') %}
{{ body.toc }}
{{ body.content }}
{# OR #}
{% set toc_options = {
'header_min': 2,
'header_max': 4,
} %}
{% set body = content.body|render|toc(toc_options) %}
{{ body.toc }}
{{ body.content }}
Depends on
Dependencies of the latest stable release
- TOC API >=2.0.0
Required by
Tracked projects that depend on this one
No tracked projects depend on this one yet.
Activity
Release Timeline
Releases
| Version | Type | Core | Notes | Release date | |
|---|---|---|---|---|---|
| 1.0.0 | Stable | 10–11 | No change from 1.0.0-beta1 | Nov 18, 2025 | |
| 1.0.0-beta1 | Pre-release | 10–11 | Initial release. | Apr 28, 2025 | |
| 1.x-dev | Dev | 10–11 | Development snapshot for toc_twig_filter 1.x | Apr 16, 2025 |