Current the Twig_Environment is hidden away in \phpbb\template\twig\twig, this makes it difficult to enable debugging in Twig, as the debug extension is not added by default (this can easily be done by checking for the DEBUG constant).
The real problem is that it doesn't not appear to be possible for phpbb extensions to register their own Twig extensions. Getting access to Twig will also allow extensions to define additional template paths if needed.
An addExtension() method would be great!
[RFC] Allow Twig Extensions
Re: [RFC] Allow Twig Extensions
The problem, is the same as here: https://area51.phpbb.com/phpBB/viewtopi ... 81&t=45709 (look at the end of the post for the available solutions)
Member of the phpBB Development-Team
No Support via PM
No Support via PM
- EXreaction
- Registered User
- Posts: 1555
- Joined: Sat Sep 10, 2005 2:15 am
Re: [RFC] Allow Twig Extensions
What do you need to add twig extensions for?
Re: [RFC] Allow Twig Extensions
We write twig extensions to make doing things in the template easier, think of them as super fancy macros. There are many cases where we need to call a custom twig function to insert special content. (ie. {{ display_special_block() }}). Without a twig extension you're pretty much blindly calling a function on every single page to set template data. There are also many twig extensions available out there that could be very useful to people.