You are here

function template_preprocess_toc_default in TOC API 8

Prepares variables for a default table of contents.

Default template: toc-default.html.twig.

Parameters

array $variables: An associative array containing the following keys:

  • toc: A TOC (table of contents) object.
  • attributes: Attributes to be added to back to top link.

File

./toc_api.module, line 206
Converts header tags into a hierarchical table of contents.

Code

function template_preprocess_toc_default(&$variables) {
  $variables['attributes'] = new Attribute($variables['attributes']);
  $variables['toc_default'] = [
    '#theme' => 'toc_tree',
    '#toc' => $variables['toc'],
    '#attributes' => [
      'class' => 'toc-default',
    ],
  ];
}