Post by JNeuhoff » Thu Oct 25, 2018 1:21 am

Why do we need Twig? They add no new improved functionality, quite to the contrary! See Daniels own notes on this in system/library/template/twig.php:

Code: Select all

	/*
	 * FYI all the Twig lovers out there!
	 * The Twig syntax is good, but the implementation and the available methods is a joke!
	 *
	 * All the Symfony developer has done is create a garbage frame work putting 3rd party scripts into DI containers.
	 * The Twig syntax he ripped off from Jinja and Django templates then did a garbage implementation!
	 *
	 * The fact that this system cache is just compiling php into more php code instead of html is a disgrace!
	 */
Why not using PHP templates? OpenCart is a PHP framework, and PHP already IS a templating system anyway!

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member
Online

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by thekrotek » Thu Oct 25, 2018 2:15 am

I second this. TWIG is hated by most OC developers, doesn't bring anything good and only makes development more complex. At least it could've been added as an alternative to default TPL.

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


User avatar
Guru Member

Posts

Joined
Wed Nov 16, 2011 11:53 am
Location - Singapore

Post by agatha65 » Tue Oct 30, 2018 9:40 am

thekrotek wrote:
Thu Oct 25, 2018 2:15 am
TWIG is hated by most OC developers, doesn't bring anything good and only makes development more complex.
+1

Suppliers Module - XML, CSV, XLS Product Feed Import and Update
Rich Snippets | Facebook Open Graph Meta Tags | WebP Images
Image


User avatar
Active Member

Posts

Joined
Fri Mar 16, 2012 10:18 am
Location - Canada, QC

Post by k2tec » Tue Oct 30, 2018 6:58 pm

Why not using PHP templates? OpenCart is a PHP framework, and PHP already IS a templating system anyway!
+1

User avatar
Active Member

Posts

Joined
Mon Apr 12, 2010 8:06 pm

Post by hamrodev » Tue Jun 18, 2019 12:26 am

I agree completely on this.
The usage of twig is - mildly put - a perfect example of overengineering that adds no additional value and was just implemented because symfony....

Newbie

Posts

Joined
Mon Jun 17, 2019 8:11 pm

Post by NikkiMarie » Mon Aug 12, 2019 1:09 am

Greetings,

Hmmm.... would I be wasting my time learning Twig to create my own theme then? Is there a real chance it will be removed from use in future releases of OC?

Many thanks!

Newbie

Posts

Joined
Sat Aug 03, 2019 8:24 am

Post by OSWorX » Mon Aug 12, 2019 3:11 am

NikkiMarie wrote:
Mon Aug 12, 2019 1:09 am
would I be wasting my time learning Twig ..
I would say, in this branche it is never a waste of time to learn new.

NikkiMarie wrote:
Mon Aug 12, 2019 1:09 am
Is there a real chance it will be removed from use in future releases of OC?
No.

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Guru Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by NikkiMarie » Sun Aug 18, 2019 1:04 pm

Very true. Wasting time was a poor choice in wording. Thanks for the reply!

Newbie

Posts

Joined
Sat Aug 03, 2019 8:24 am

Post by johanvandemerwe » Wed Sep 16, 2020 4:42 pm

I am so glad that Opencart got rid of that very ugly and complex PHP templating. Laravel f.e. is using Blade as template engine, while it is a PHP framework. I really hate to see html files that contain all that ugly <?php and ?> repetition to add values from a controller in it. Twig is for me the right way to go.

Twig is very easy to learn and very easy to extend with your own functions and filters. Twig is for me a very useful addition to PHP and I use it all the time. In fact I would never use a framework or CMS again is still using PHP as template engine.

Twig is widely accepted as a template standard. If you like to code less, use Twig, if you like to keep repeating yourself stay with putting a lot of PHP overhead in your templates.


Posts

Joined
Thu Jun 27, 2019 6:26 pm

Post by JNeuhoff » Wed Sep 16, 2020 11:30 pm

@johanvandemerwe : Yours sounds like a fan post here.

Daniel, the author of OpenCart, said this about TWIG:
The Twig syntax is good, but the implementation and the available methods is a joke!
...
The fact that this system cache is just compiling php into more php code instead of html is a disgrace!
There are countless examples in the IT industry where people use poor quality software. The same is true with many OpenCart extensions.

As regards Twig: At least it's possible with our Template Switcher extension to also use PHP templates.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member
Online

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by johnp » Thu Sep 17, 2020 12:12 am

Twig is on the same level as Magento for me. Best given a wide berth.

Opencart 1.5.6.5/OC Bootstrap Pro/VQMOD lover, user and geek.
Affordable Service £££ - Opencart Installs, Fixing, Development and Upgrades
Plus Ecommerce, Marketing, Mailing List Management and More
FREE Guidance and Advice at https://www.ecommerce-help.co.uk


User avatar
Active Member

Posts

Joined
Fri Mar 25, 2011 10:25 am
Location - Surrey, UK

Post by mackjone » Mon Sep 21, 2020 7:55 pm

I second this. TWIG is abhorred by most OC engineers, doesn't bring anything great and just makes advancement more intricate

Newbie

Posts

Joined
Mon Sep 14, 2020 6:26 pm

Post by Naheed » Wed Oct 07, 2020 8:33 pm

Twig is fast enough, and it is a useful addition to PHP. Moreover, Twig can be used as a template language for developers
to adjust the template design. It is flexible enough for all our requirements, even the most difficult ones.

User avatar
Active Member

Posts

Joined
Mon Aug 10, 2020 11:19 pm

Post by JNeuhoff » Wed Oct 07, 2020 8:48 pm

Naheed wrote:
Wed Oct 07, 2020 8:33 pm
Twig is fast enough, and it is a useful addition to PHP. Moreover, Twig can be used as a template language for developers
to adjust the template design. It is flexible enough for all our requirements, even the most difficult ones.
As I said, with Twig compiling php into more php code instead of html is just no good. A template engine super-imposed upon another template engine, crazy!

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member
Online

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by JNeuhoff » Sun Dec 13, 2020 7:43 pm

Now that OpenCart 4.0.0.0 is on its way, I thought it might be a good time to address the issue of Twig again.

IMHO there was never a need for Twig, but Daniel doesn't appear wanting to abandon it yet for the time being. However, his comment about Twig, shown below, has some valid points:
FYI all the Twig lovers out there!

The Twig syntax is good, but the implementation and the available methods is a joke!

All the Symfony developer has done is create a garbage frame work putting 3rd party scripts into DI containers.
The Twig syntax he ripped off from Jinja and Django templates then did a garbage implementation!

The fact that this system cache is just compiling php into more php code instead of html is a disgrace!
I have started writing up our own Twig engine which can directly translate a twig template plus variables to the final HTML output, without compiling into an intermediate cached PHP code . It's still in the early stages, the first tests, using the common/footer.twig, show promising performance results:

common/footer.twig: average 0.000257 seconds (on OC 4.0.0.0-b with Symfony Twig, cache enabled)
common/footer.twig: average 0.000069 seconds (on OC 4.0.0.0-b with our own Twig to HTML rendering engine

There are several directions we can go:
  • Compile twig directly into the final HTML
  • An option to permanently convert all twig files into PHP templates
  • An OpenCart extension allowing for both Twig and PHP templates

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member
Online

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by govinda4india » Sat Jul 17, 2021 9:08 pm

You cannot even use every functionality of Twig here which Symfony provides, this Opencart Twig sucks.

Newbie

Posts

Joined
Fri Sep 08, 2017 10:15 pm

Post by JNeuhoff » Sat Jul 17, 2021 9:21 pm

govinda4india wrote:
Sat Jul 17, 2021 9:08 pm
You cannot even use every functionality of Twig here which Symfony provides, this Opencart Twig sucks.
Which can be a good thing, because the business logic belongs to the controller, not the view-rendering.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member
Online

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by crossvid » Tue Sep 28, 2021 5:35 pm

Why not using PHP templates? OpenCart is a PHP framework, and PHP already IS a templating system anyway!

vidmate app save insta


Newbie

Posts

Joined
Tue Sep 28, 2021 4:27 pm

Post by rjcalifornia » Wed Sep 29, 2021 10:50 pm

It might surprise you, but Twig forces you to keep the business logic in the Controllers. I understand the sentiment, changes are never easy. However, please compare any opencart view with Twig and another one without it (older opencart), and you will notice the code is cleaner and actually readable.

PHP is a template engine, but the quality of extensions/themes you get by using Twig improves. Twig forces you to stop doing hacks to your theme views (Go ahead and check old OpenCart themes)

Image
A2 Hosting features: Shared Turbo Boost, Managed Warp 1, Unmanaged Hyper 1, and Warp 2 Turbo


Active Member

Posts

Joined
Fri Sep 02, 2011 1:19 pm
Location - Worldwide
Who is online

Users browsing this forum: SohBH and 46 guests