page = $page; } /** * Get the view / contents that represent the component. */ public function render(): View|Closure|string { return view('components.page-renderer'); } /** * Render the header template with data */ public function renderHeader(): string { if (!$this->page->headerTemplate) { return ''; } return TemplateService::replacePlaceholders( $this->page->headerTemplate->html_content, $this->page->header_data ?? [] ); } /** * Render all sections with their templates */ public function renderSections(): string { $output = ''; foreach ($this->page->templated_sections as $section) { if (!$section['template']) { continue; } $output .= TemplateService::replacePlaceholders( $section['template']->html_content, $section['data'] ); } return $output; } /** * Render the footer template with data */ public function renderFooter(): string { if (!$this->page->footerTemplate) { return ''; } return TemplateService::replacePlaceholders( $this->page->footerTemplate->html_content, $this->page->footer_data ?? [] ); } }