шаг 1 сделан
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Core;
|
||||
|
||||
final class View
|
||||
{
|
||||
public static function render(string $template, array $data = []): void
|
||||
{
|
||||
$templatePath = base_path('views/' . trim($template, '/') . '.php');
|
||||
|
||||
if (!is_file($templatePath)) {
|
||||
http_response_code(500);
|
||||
echo 'Template not found';
|
||||
return;
|
||||
}
|
||||
|
||||
extract($data, EXTR_SKIP);
|
||||
|
||||
require base_path('views/layouts/main.php');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user