<?php
namespace IcreatorCookieConsent;

if (!defined('ABSPATH')) exit;

class View {
    public static function render(string $template, array $data = []): void {
        $file = ICCB_ROOT_PATH . 'includes/views/' . ltrim($template, '/') . '.php';
        if (!file_exists($file)) {
            /* translators: %s is the missing view template name. */
            echo '<div class="notice notice-error"><p>' . esc_html(sprintf(__('View not found: %s', 'consentpress'), $template)) . '</p></div>';
            return;
        }
        extract($data, EXTR_SKIP);
        include $file; // templates contain only markup, no business logic
    }
}
