20 lines
438 B
PHP
20 lines
438 B
PHP
<?php
|
|
|
|
namespace App\Core;
|
|
|
|
class View
|
|
{
|
|
public static function render(string $template, array $data = []): string
|
|
{
|
|
$path = base_path('resources/views/' . $template . '.php');
|
|
if (!file_exists($path)) {
|
|
throw new \RuntimeException('View not found: ' . $template);
|
|
}
|
|
|
|
extract($data, EXTR_SKIP);
|
|
ob_start();
|
|
include $path;
|
|
return (string) ob_get_clean();
|
|
}
|
|
}
|