Added new functions to the render helper that render the global variables and EALang scripts into a view file

This commit is contained in:
alextselegidis 2021-11-09 08:40:20 +01:00
parent 6d567a74a4
commit 6c356aec50
3 changed files with 52 additions and 1 deletions

View file

@ -18,7 +18,7 @@
*
* @return string
*/
function render_timezone_dropdown($attributes = '')
function render_timezone_dropdown(string $attributes = ''): string
{
$CI = get_instance();
@ -31,3 +31,35 @@ function render_timezone_dropdown($attributes = '')
'attributes' => $attributes
], TRUE);
}
/**
* Render the language script tag.
*
* @param string $attributes HTML element attributes of the script element.
*
* @return string
*/
function render_language_script(string $attributes = ''): string
{
$CI = get_instance();
return $CI->load->view('partials/language_script', [
'attributes' => $attributes
], TRUE);
}
/**
* Render the global variables script tag.
*
* @param string $attributes HTML element attributes of the script element.
*
* @return string
*/
function render_global_variables_script(string $attributes = ''): string
{
$CI = get_instance();
return $CI->load->view('partials/global_variables_script', [
'attributes' => $attributes
], TRUE);
}

View file

@ -0,0 +1,10 @@
<?php
/**
* @var string $attributes
* @var array $global_variables
*/
?>
<script <?= $attributes ?>>
const GlobalVariables = <?= json_encode($global_variables ?? []) ?>
</script>

View file

@ -0,0 +1,9 @@
<?php
/**
* @var string $attributes
*/
?>
<script <?= $attributes ?>>
const EALang = <?= json_encode($this->lang->language) ?>
</script>