Hi I'm trying to register all user defined functions in twig but it seems not to work.
Here's my approach:
// begins here
$this->CI =& get_instance();
$this->CI->load->helper('array');
foreach ( element('user', get_defined_functions()) as $v){
//echo $v;
//echo
$this->funcx($v);
}
/**
* Register a function in Twig environment
*
**/
public function funcx($name)
{
$this->twig->addFunction(
new Twig_SimpleFunction(
$name,
$name
));
return $this;
}
// ends here
I have defined functions such as script() assets() doo() inside a helper file which has been loaded.
In my template I used {{ doo() }} as an example but I get this error message :
//begins here
An uncaught Exception was encountered
Type: Twig_Error_Syntax
Message: Unknown "doo" function.
// ends here
Hi I'm trying to register all user defined functions in twig but it seems not to work. Here's my approach:
I have defined functions such as script() assets() doo() inside a helper file which has been loaded. In my template I used {{ doo() }} as an example but I get this error message :