The component helper function will now have a single vars argument for both attributes and params.
This commit is contained in:
parent
c9fd813d0b
commit
626d8b86a1
1 changed files with 4 additions and 9 deletions
|
@ -23,24 +23,19 @@ if ( ! function_exists('component'))
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
*
|
*
|
||||||
* echo component('timezones_dropdown', 'class"form-control"');
|
* echo component('timezones_dropdown', ['attributes' => 'class"form-control"'], TRUE);
|
||||||
*
|
*
|
||||||
* @param string $component Component template file name.
|
* @param string $component Component template file name.
|
||||||
* @param string $attributes HTML attributes for the parent component element.
|
* @param array $vars Additional parameters for the component.
|
||||||
* @param array $params Additional parameters for the component.
|
|
||||||
* @param bool $return Whether to return the HTML or echo it directly.
|
* @param bool $return Whether to return the HTML or echo it directly.
|
||||||
*
|
*
|
||||||
* @return string Return the HTML if the $return argument is TRUE or NULL.
|
* @return string Return the HTML if the $return argument is TRUE or NULL.
|
||||||
*/
|
*/
|
||||||
function component(string $component, string $attributes = '', array $params = [], bool $return = FALSE)
|
function component(string $component, array $vars = [], bool $return = FALSE)
|
||||||
{
|
{
|
||||||
/** @var EA_Controller $CI */
|
/** @var EA_Controller $CI */
|
||||||
$CI = get_instance();
|
$CI = get_instance();
|
||||||
|
|
||||||
$vars = array_merge($params, [
|
|
||||||
'attributes' => $attributes
|
|
||||||
]);
|
|
||||||
|
|
||||||
return $CI->load->view('components/' . $component, $vars, $return);
|
return $CI->load->view('components/' . $component, $vars, $return);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,7 +89,7 @@ if ( ! function_exists('section'))
|
||||||
$layout['sections'][$name][] = ob_get_clean();
|
$layout['sections'][$name][] = ob_get_clean();
|
||||||
|
|
||||||
unset($layout['tmp'][$name]);
|
unset($layout['tmp'][$name]);
|
||||||
|
|
||||||
config(['layout' => $layout]);
|
config(['layout' => $layout]);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue