Tpl: add var_dump function

This commit is contained in:
Benjamin Renard 2023-02-15 19:00:25 +01:00
parent d304d4741f
commit 98f61c36eb

View file

@ -172,6 +172,8 @@ class Tpl {
foreach(App :: get('templates.static_directories', array(), 'array') as $path) foreach(App :: get('templates.static_directories', array(), 'array') as $path)
self :: register_static_directory($path); self :: register_static_directory($path);
self :: register_function('var_dump', array('EesyPHP\\Tpl', 'smarty_var_dump'));
} }
} }
@ -698,4 +700,15 @@ class Tpl {
$url = self :: static_url($params['path']); $url = self :: static_url($params['path']);
if ($url) echo $url; if ($url) echo $url;
} }
/**
* Smarty function to dump variable using var_dump()
* @param array<string,mixed> $params Parameters from template file
* @param Smarty $smarty The smarty object
* @return void
*/
public static function smarty_var_dump($params, $smarty) {
if (!isset($params['data'])) return;
var_dump($params['data']);
}
} }