You are here

public function TocBuilder::renderToc in TOC API 8

Renders a table of contents navigation.

Parameters

\Drupal\toc_api\TocInterface $toc: A TOC object.

Return value

\Drupal\Component\Render\MarkupInterface The rendered table of contents.

Overrides TocBuilderInterface::renderToc

File

src/TocBuilder.php, line 106

Class

TocBuilder
Defines a service that builds and renders a table of contents and update an HTML document's headers.

Namespace

Drupal\toc_api

Code

public function renderToc(TocInterface $toc) {
  if (!$toc
    ->isVisible()) {
    return '';
  }
  $build = $this
    ->buildToc($toc);
  return $this->renderer
    ->render($build);
}