I'm trying to attach the hook initTwig into the template (_init.php), but it doesn't work.
wire()->addHookAfter("TemplateEngineTwig::initTwig",function(HookEvent $event){
$twig = $event->arguments('twig');// Extend $twig with custom code});
By now, I'm able to hook it correctlyonly by hooking within a class (for example a class defined in a module), but sometimes it's useful to extend it directly from a template without the hassle of dealing with a module.
Module: Twig for the TemplateEngineFactory
in Modules/Plugins
Posted
I'm trying to attach the hook initTwig into the template (_init.php), but it doesn't work.
By now, I'm able to hook it correctly only by hooking within a class (for example a class defined in a module), but sometimes it's useful to extend it directly from a template without the hassle of dealing with a module.
Anyone experiencing the same issue?
Thanks!