$data * @param array $options Unused - reserved for third-party extensions. */ function view(string $name, array $data = [], array $options = []): string { $path = Theme::path(); /** @var CodeIgniter\View\View $renderer */ $renderer = single_service('renderer', $path); $saveData = config(View::class)->saveData; if (array_key_exists('saveData', $options)) { $saveData = (bool) $options['saveData']; unset($options['saveData']); } return $renderer->setData($data, 'raw') ->render($name, $options, $saveData); } } if (! function_exists('lang')) { /** * A convenience method to translate a string or array of them and format the result with the intl extension's * MessageFormatter. * * Overwritten to include an escape parameter (escaped by default). * * @param array $args * * @return string|string[] */ function lang(string $line, array $args = [], ?string $locale = null, bool $escape = true): string | array { $language = Services::language(); // Get active locale $activeLocale = $language->getLocale(); if ($locale && $locale !== $activeLocale) { $language->setLocale($locale); } $line = $language->getLine($line, $args); if (! $locale) { return $escape ? esc($line) : $line; } if ($locale === $activeLocale) { return $escape ? esc($line) : $line; } // Reset to active locale $language->setLocale($activeLocale); return $escape ? esc($line) : $line; } }