amteich / kirby-twig

Twig templating support for Kirby CMS
MIT License
48 stars 12 forks source link

mgfagency\Twig\Plugin::render fails if called from a route handler #7

Closed drapisarda closed 5 years ago

drapisarda commented 5 years ago

Hallo! I just found what seams to be a bug. I'm trying to use the twig() helper from a Kirby v3 route handler, then this error is shout

Too few arguments to function mgfagency\Twig\Environment::__construct(), 0 passed in /Users/daniele/projects/v3-kirby/kirby/site/plugins/kirby-twig/src/classes/Environment.php on line 206 and exactly 1 expected

Looks like that the Environment is not properly instantiated. This makes the call to the static method Environment::instance() try to re create the instance (Environment.php:206), and it fails with the error shown.

It also happens that if, before to use twig(), i call the findPageOrDraft method of a site instance, twig() works good (the Environment is properly instantiated);

I hope you can give me some advice to how to handle this scenario. If you need any other information, I will provide them as soon as possible. Thank you in advice.