Fixed error in render_info macro.

This commit is contained in:
flash 2022-08-11 23:28:45 +00:00
parent 33bf839689
commit 88b3acf08e

View file

@ -103,24 +103,18 @@ function render_error(int $code, string $template = 'errors.%d'): string {
function render_info(?string $message, int $httpCode, string $template = 'errors.%d'): string {
http_response_code($httpCode);
try {
\Misuzu\Template::set('http_code', $httpCode);
\Misuzu\Template::set('http_code', $httpCode);
if(mb_strlen($message)) {
\Misuzu\Template::set('message', $message);
}
if(!empty($message))
\Misuzu\Template::set('message', $message);
$template = sprintf($template, $httpCode);
$template = sprintf($template, $httpCode);
/*if(!tpl_exists($template)) {
$template = 'errors.master';
}*/
/*if(!tpl_exists($template)) {
$template = 'errors.master';
}*/
return \Misuzu\Template::renderRaw(sprintf($template, $httpCode));
} catch(Exception $ex) {
echo $ex->getMessage();
return $message ?? '';
}
return \Misuzu\Template::renderRaw(sprintf($template, $httpCode));
}
function render_info_or_json(bool $json, string $message, int $httpCode = 200, string $template = 'errors.%d'): string {