Twig as our template engine

These requests for comments/change have lead to an implemented feature that has been successfully merged into the 3.1/Ascraeus branch. Everything listed in this forum will be available in phpBB 3.1.
Post Reply
User avatar
paulus
Infrastructure Team Leader
Infrastructure Team Leader
Posts: 361
Joined: Thu Sep 16, 2004 9:02 am
Contact:

Re: [RFC] Twig as our template engine

Post by paulus » Wed Jun 19, 2013 6:34 am

*Daniel wrote:Guys,

Didn't you say that you were going to make phpBB 3.1 so that we can use mods written for phpBB 3.0? If you move to this new framework then we are going to be *beep* as there many changes that would be required.

What happen to backward compatibility‎?

No wonder why people are moving away or won't be upgrading.
Even without the change to twig (What, like Nathan said, support the old phpBB syntax) you wont be able to use 3.0 MODs in most cases. MODs like in phpBB3 should not exists anymore in 3.1, they should be rewritten to extensions instead.
Image

User avatar
Marc
Development Team Leader
Development Team Leader
Posts: 123
Joined: Thu Sep 09, 2010 11:36 am
Location: Munich, Germany

Re: [RFC] Twig as our template engine

Post by Marc » Thu Jun 20, 2013 10:37 am

*Daniel wrote:Guys,

Didn't you say that you were going to make phpBB 3.1 so that we can use mods written for phpBB 3.0? If you move to this new framework then we are going to be *beep* as there many changes that would be required.

What happen to backward compatibility‎?

No wonder why people are moving away or won't be upgrading.
As you might have noticed, EXreaction said that he's currently writing code to support the current phpBB syntax which also means that backwards compatibility is mainly preserved.

User avatar
Arty
Registered User
Posts: 970
Joined: Wed Mar 06, 2002 2:36 pm
Location: Mars
Contact:

Re: [RFC] Twig as our template engine

Post by Arty » Sun Jun 23, 2013 7:36 pm

Template system for 3.1 was not designed to be extendable, it can't even handle extensions properly and its abstraction makes it look like it was designed that way for sake of creating multiple classes, not for benefit of anyone.

So move to twig is the best thing that can happen to phpBB. Twig already includes all functionality that current template system lacks and later can be used to switch from old smarty-like template system to twig system used by many projects.
Formerly known as CyberAlien.

Free phpBB styles | Premium responsive XenForo styles

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

Re: [RFC] Twig as our template engine

Post by EXreaction » Tue Jul 02, 2013 4:48 pm

I believe the PR for this has been mostly completed. The only issue remaining is that some of the functional tests are failing, though for what reason, I am not sure.

There is a lot of code that can be cleaned up still related to the styles/template system, but I'm going to leave those for later as it works as-is and I wish to keep this PR as small as possible.

With the Twig PR, the only syntax that has changed slightly is the INCLUDEJS, no longer is it only limited to a path within the style tree (can use @namespace to include files also) and no longer do you need to append template/ to the path. INCLUDEJS was not in 3.0, so this does not break any compatibility.

All of the functionality of Twig is able to be used now as well (all tags, filters, functions, and operators) using the standard Twig tokens {% %}, {{ }}. Some of this functionality is now also available in phpBB syntax (e.g. <!-- IF loop|length > 3 -->). You cannot use Twig only functionality (e.g. for) using phpBB open/close tags (e.g. <!-- for item in items -->) as only existing phpBB template tags are transformed to Twig functionality.

See http://twig.sensiolabs.org/doc/templates.html for more information on how to use Twig syntax.

When Twig is merged, I will try to get around to a new templating guide explaining how to use Twig syntax as well (though the Twig documentation is very good already).

User avatar
MichaelC
Development Team
Development Team
Posts: 889
Joined: Thu Jan 28, 2010 6:29 pm

Re: [RFC] Twig as our template engine

Post by MichaelC » Tue Jul 02, 2013 8:12 pm

And coding guidelines will need adjusting detailing which to use in which cases?
Formerly known as Unknown Bliss
psoTFX wrote: I went with Olympus because as I said to the teams ... "It's been one hell of a hill to climb"
No unsolicited PMs please except for quotes.

User avatar
imkingdavid
Registered User
Posts: 1050
Joined: Thu Jul 30, 2009 12:06 pm

Re: [RFC] Twig as our template engine

Post by imkingdavid » Wed Jul 03, 2013 3:34 am

For consistency, it might be good to look into masking twig functions with our own syntax (for instance, what you did with INCLUDEJS) so that we don't have two syntaxes in the same file. It's more work, but would help save some confusion.
I do custom MODs. PM for a quote!
View My: MODs | Portfolio
Please do NOT contact for support via PM or email.
Remember, the enemy's gate is down.

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

Re: [RFC] Twig as our template engine

Post by EXreaction » Thu Jul 04, 2013 4:27 pm

That would be one option, it would just be a simple regular expression to setup masks for all the twig tags.

I would need to tweak some of my existing regular expressions to support filters and stuff, as well as make tests for all of it.

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

Re: [RFC] Twig as our template engine

Post by EXreaction » Thu Jul 04, 2013 5:47 pm

Alright, I've done all that except for the testing part. Can now use all the Twig tokens as <!-- uppercase(twig token) -->. E.g. <!-- BLOCK foo -->

Can also use filters in our variable tags. E.g. {SITENAME|lower}

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

Re: [RFC] Twig as our template engine

Post by EXreaction » Thu Jul 04, 2013 8:36 pm

All tests are now passing on this PR.

User avatar
Kamahl19
Registered User
Posts: 161
Joined: Thu Dec 27, 2007 10:31 am

Re: [RFC] Twig as our template engine

Post by Kamahl19 » Fri Jul 05, 2013 3:05 am

Good work. So know phpbb has 2 template engines? Or have you removed the old one and added Twig + syntax from old engine on top of Twig?

Post Reply