diff --git a/public/index.php b/public/index.php index 24595aa..0a7084d 100644 --- a/public/index.php +++ b/public/index.php @@ -47,5 +47,6 @@ if ($match !== null) { } } +$content = new MapGuesser\Response\HtmlContent('error/404'); header('Content-Type: text/html; charset=UTF-8', true, 404); -require ROOT . '/views/error/404.php'; +echo $content->render(); diff --git a/src/Response/HtmlContent.php b/src/Response/HtmlContent.php index 0ad813a..8664cf8 100644 --- a/src/Response/HtmlContent.php +++ b/src/Response/HtmlContent.php @@ -1,21 +1,28 @@ template = $template; + $this->view = $view; $this->data = &$data; } public function &render(): string { + if (!empty($_ENV['DEV'])) { + $generator = new Linker($this->view); + $generator->generate(); + } + extract($this->data); ob_start(); - require ROOT . '/views/' . $this->template . '.php'; + require ROOT . '/cache/views/' . $this->view . '.php'; $content = ob_get_contents(); ob_end_clean();