, , , header, or footer). * * Usage: * * // public/admin/fragments/licence.php * AdminAuth::requireLogin(); * FragmentRenderer::render('form/_licence', [ * 'accessTypeId' => $_POST['access_type_id'] ?? '', * 'licenseId' => $_POST['license_id'] ?? '', * 'licenseTypes' => Database::getInstance()->getAllLicenseTypes(), * 'cc2r' => !empty($_POST['cc2r']), * 'wantLicense' => !empty($_POST['want_license']), * 'adminMode' => true, * 'hxPost' => '/admin/fragments/licence.php', * ]); * * The template receives all keys in $data as variables via extract(). */ class FragmentRenderer { /** * Render a template partial for an HTMX fragment response. * * @param string $template Path relative to APP_ROOT/templates/partials/ (without .php extension) * @param array $data Variables to extract into template scope */ public static function render(string $template, array $data = []): void { // Prevent output buffering from any wrapping layout if (ob_get_level() === 0) { ob_start(); } extract($data, EXTR_SKIP); require APP_ROOT . '/templates/partials/' . $template . '.php'; ob_end_flush(); } }