[RFC] Allow Twig Extensions

Note: We are moving the topics of this forum and it will be deleted at some point

Publish your own request for comments/change or patches for the next version of phpBB. Discuss the contributions and proposals of others. Upcoming releases are 3.2/Rhea and 3.3.
Post Reply
User avatar
rfdy
Registered User
Posts: 45
Joined: Wed Apr 16, 2014 2:28 pm

[RFC] Allow Twig Extensions

Post by rfdy »

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!

Nicofuma
3.2 Release Manager
3.2 Release Manager
Posts: 299
Joined: Sun Apr 13, 2014 1:40 am
Location: Paris

Re: [RFC] Allow Twig Extensions

Post by Nicofuma »

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

User avatar
EXreaction
Registered User
Posts: 1555
Joined: Sat Sep 10, 2005 2:15 am

Re: [RFC] Allow Twig Extensions

Post by EXreaction »

What do you need to add twig extensions for?

User avatar
rfdy
Registered User
Posts: 45
Joined: Wed Apr 16, 2014 2:28 pm

Re: [RFC] Allow Twig Extensions

Post by rfdy »

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.

Post Reply