Thank for the reply.
I looked closer at how templates are rendered in the View class of CI4 and decided not to use them at all. Instead I just render views.
In order to pass common data to views like header or footer I added a simple static variable in BaseController class. The variable is just an associative array. It contains keys and values.
PHP Code:
public static $globals = [];
If I need to add some global data somewhere, like in the BaseController, I just create a key and assign a value.
PHP Code:
self::$globals['key'] = 'value';
Then in my view:
PHP Code:
esc(\App\Controller\BaseController::$globals['key']);
It is ugly quick fix, but dealing with the mess made with templates in CI4 is even worse.