Skip to content

Commit

Permalink
Testing, documentation & refactoring in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
rotimi committed Feb 3, 2024
1 parent c7d1efc commit 22254b7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/HtmlErrorRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ public function renderHtmlBody(string $title = '', string $html = ''): string {

$file_contents = file_get_contents($this->path_to_error_template_file);

return sprintf($file_contents, $title, $title, $html);
return str_replace(
['{{{TITLE}}}', '{{{ERROR_HEADING}}}', '{{{ERROR_DETAILS}}}'],
[$title, $title, $html],
$file_contents
);
}

private function renderExceptionFragment(\Throwable $exception): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>%s</title> <!-- title injected by \SlimMvcTools\HtmlErrorRenderer->renderHtmlBody(string $title = '', string $html = '') -->
<title>{{{TITLE}}}</title> <!-- title injected by \SlimMvcTools\HtmlErrorRenderer->renderHtmlBody(string $title = '', string $html = '') -->
<style>
body{margin:0;padding:30px;font:12px/1.5 Helvetica,Arial,Verdana,sans-serif}
h1{margin:0;font-size:48px;font-weight:normal;line-height:48px}
strong{display:inline-block;width:65px}
</style>
</head>
<body>
<h1>%s</h1>
<div>%s</div>
<h1>{{{ERROR_HEADING}}}</h1>
<div>{{{ERROR_DETAILS}}}</div>
<a href="#" onclick="window.history.go(-1)">Go Back Yooooooooooo</a>
</body>
</html>

0 comments on commit 22254b7

Please sign in to comment.