<?php
namespace App\Core;

class View
{
    public static function render(string $tpl, array $data = [], ?string $layout = null): void
    {
        \extract($data);
        \ob_start();
        require ROOT . '/resources/views/' . $tpl . '.php';
        $content = \ob_get_clean();
        if ($layout) require ROOT . '/resources/views/layouts/' . $layout . '.php';
        else echo $content;
    }
}
