[RFC] Gradually switch to TWIG template syntax

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.
User avatar
Arty
Former Team Member
Posts: 985
Joined: Wed Mar 06, 2002 2:36 pm
Location: Mars
Contact:

[RFC] Gradually switch to TWIG template syntax

Post by Arty »

Currently phpBB 3.1 supports both old phpBB template syntax and TWIG syntax. There are issues with phpBB template syntax because it is very different from what TWIG was designed for. Almost ("almost" because I'm not sure about INCLUDEJS) every keyword can be easily converted to TWIG format.

I suggest to start gradually switching from phpBB template syntax to TWIG in template files with eventual goal to completely abandon phpBB template syntax in future.

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

Re: [RFC] Gradually switch to TWIG template syntax

Post by EXreaction »

This would have a few big advantages and disadvantages.

+ Once everything were to be moved over, we can greatly simplify the template engine and remove all the complex parsing that is done to transform our code to Twig
+ Using all Twig code would make it easier for users; it's better documented, more universally used/supported

- Moving over completely isn't something that's realistically likely to happen in either prosilver or subsilver2
- Users will probably be quite confused when they run into the two different types of syntax

Those items being said, I'm not sure whether transitioning to Twig syntax in our existing templates is a good idea due to the confusion our users will likely have.

If a new style were to be made for 3.x, I would definitely support using all Twig syntax in it and deprecating our old syntax.

User avatar
Pony99CA
Registered User
Posts: 986
Joined: Sun Feb 08, 2009 2:35 am
Location: Hollister, CA
Contact:

Re: [RFC] Gradually switch to TWIG template syntax

Post by Pony99CA »

I agree with EX. "Gradually" switching over seems like it would be more confusing, even if done one template file at a file. If you plan to convert existing styles, the whole style should be done at once (if possible).

Steve
Silicon Valley Pocket PC (http://www.svpocketpc.com)
Creator of manage_bots and spoof_user (ask me)
Need hosting for a small forum with full cPanel & MySQL access? Contact me or PM me.

User avatar
hanakin
Front-End Dev Team Lead
Front-End Dev Team Lead
Posts: 968
Joined: Sat Dec 25, 2010 9:02 pm
Contact:

Re: [RFC] Gradually switch to TWIG template syntax

Post by hanakin »

agree a new template built from twig would be a better and probably faster approach anyway. The question then becomes how long do we support the others? and do we continue to update their codebase to be more modern or just add enhancements?
Donations welcome via Paypal Image

User avatar
Mess
Registered User
Posts: 199
Joined: Wed Jun 13, 2012 10:14 am

Re: [RFC] Gradually switch to TWIG template syntax

Post by Mess »

I agree, creating a new style using TWIG exclusively would make more sense to me. Would also give style designers a new base to work off.

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

Re: [RFC] Gradually switch to TWIG template syntax

Post by EXreaction »

We would probably continue to support the old syntax for a few years/versions after we switch to only Twig syntax in a release.

The entire prosilver style could be switched to Twig syntax relatively easily too using some mass search/replace (could be done with a script so everyone could run it and update their styles). If this is something we'd like to do, it could be done for 3.2.

VEG
Registered User
Posts: 1
Joined: Mon Apr 02, 2007 11:14 am

Re: [RFC] Gradually switch to TWIG template syntax

Post by VEG »

Why not Smarty? Twig is too slow. See this article.

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

Re: [RFC] Gradually switch to TWIG template syntax

Post by EXreaction »

That article is extremely old and was tested with recent builds from that time period. A more recent test shows Twig is actually significantly faster:
http://sapphirepaw.blogspot.com/2013/08 ... art-1.html

But then again, I don't typically trust benchmarks found online; they are typically not done in a controlled enough environment to get really accurate results, not to mention benchmarks rarely use real life examples which are far more important than a small benchmark that doesn't have a lot of coverage of feature usage. Just because one is faster at one thing doesn't mean that it will overall be faster on average.

We've already switched our template engine to Twig; Smarty just doesn't have the same feature set that Twig does and didn't meet our needs.

User avatar
nickvergessen
Former Team Member
Posts: 733
Joined: Sun Oct 07, 2007 11:54 am
Location: Stuttgart, Germany
Contact:

Re: [RFC] Gradually switch to TWIG template syntax

Post by nickvergessen »

I'm also against changing prosilver to a different syntax.

We agreed switching to twig with the condition to keep the current syntax, so users are not bugged with it.
Member of the Development-TeamNo Support via PM

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

Re: [RFC] Gradually switch to TWIG template syntax

Post by Kamahl19 »

Ok so when will be twig actually used?
Many SW changed their template engine, yes it was confusing at first and some difficulties occurred, but thats the progress. Moreover, those softwares had only one template engine syntax, phpBB 3.1 will support both, new and old one. I personally would use twig in prosilver 3.1 without hesitating.

Post Reply