<?php

declare(strict_types=1);

namespace FatBottom\Core;

final class View
{
    public static function render(string $template, array $data = []): void
    {
        $templatePath = BASE_PATH . '/views/' . $template . '.php';
        if (!is_file($templatePath)) {
            Http::abort(500, 'View not found.');
        }

        extract($data, EXTR_SKIP);
        require BASE_PATH . '/views/layout.php';
    }

    public static function partial(string $template, array $data = []): void
    {
        extract($data, EXTR_SKIP);
        require BASE_PATH . '/views/' . $template . '.php';
    }
}

