document = $document; $this->templateRenderer = $templateRenderer; } public function render(): string { return (new BaseDocumentRender($this->document))->render(); } public function renderDocument(): string { $headerNodes = ''; foreach ($this->document->getHeaderNodes() as $node) { $headerNodes .= $node->render() . "\n"; } $html = $this->templateRenderer->render('document.html.twig', [ 'headerNodes' => $headerNodes, 'bodyNodes' => $this->render(), ]); if ($this->document->getConfiguration()->getIndentHTML()) { return $this->indentHTML($html); } return $html; } private function indentHTML(string $html): string { return (new Indenter())->indent($html); } }