Well, only to a degree. In the latest Twig releases there are a number of functions or filters whose logic should really be in the controllers and not in Twig.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)
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
Because people didn't know how to use them back then and most still don't know how to use them now. In addition, it reduces the error triggers whenever an issue is addressed on screen while even forum supporters could propose to disable these messages. Which means, in either scenarios, whether the logs are disabled or the TWIG files being tweaked all over the template still won't show the error messages on anyhow - unless using a TWIG debugger to see the error messages specifically from the TWIG Engine.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
Whether the right or the wrong use of the variables, most of the people still don't know what to do with them without requesting assistance especially on production servers.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
I understand the sentiment. However, Twig makes the code more readable and cleaner. Take a look at a simple foreach loop with PHP/HTML:
Code: Select all
<table>
<?php foreach($array as $key=>$value): ?>
<tr>
<td><?php echo $key; ?></td>
</tr>
<?php endforeach; ?>
</table>
Code: Select all
<table>
{% for key in users|keys %}
<tr>
<td>{{ key }}</td>
</tr>
{% endfor %}
</table>
A2 Hosting features: Shared Turbo Boost, Managed Warp 1, Unmanaged Hyper 1, and Warp 2 Turbo
Sorry, but wtf - why should an enduser "understand" the code?rjcalifornia wrote: ↑Thu Sep 30, 2021 9:33 pmI understand the sentiment. However, Twig makes the code more readable and cleaner.
He wants to have only an always working store.
And developers should know their job, no matter if php or/and twig or something else.
At the end, the code should be fast to parse, loading sites therefore fast.
Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.
While speed optimization via template is imminent for developers, the point on using the TWIG Engine also reflects on web design which does not specifically reflect on PHP languages.OSWorX wrote: ↑Thu Sep 30, 2021 9:45 pmSorry, but wtf - why should an enduser "understand" the code?rjcalifornia wrote: ↑Thu Sep 30, 2021 9:33 pmI understand the sentiment. However, Twig makes the code more readable and cleaner.
He wants to have only an always working store.
And developers should know their job, no matter if php or/and twig or something else.
At the end, the code should be fast to parse, loading sites therefore fast.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Your example actually demonstrates why Twig has a poorer, not better syntax. Twig is not based on proper parser technologies because of the lack of a clean underlying Twig language syntax (e.g. it's not a clean LALR(1) grammar). Just look at the recently introduced Twig arrow functions as an example to see how messy its syntax truly is!I understand the sentiment. However, Twig makes the code more readable and cleaner. Take a look at a simple foreach loop with PHP/HTML:
OSWorX is right here: The template rendering engine needs to be fast, not so bloated or slow like Symfony Twig.
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
Performance improvements vary, depending on OpenCart version, PHP version, and twig-templates being used, from around 20% to 50% faster speeds, or sometimes even more.
As regards implemented features in OpenTwig: See the documentation for more details. We are running several websites, with different themes, just fine using OpenTwig.
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
Opencart 4 default homepage
Stock TWIG: 0.028 sec
OpenTwig: 0.109 sec
OpenTwig in this test is 3 times slower than the stock TWIG. Am I doing something wrong?
Also, theoretically - how can a parser written in PHP be faster than PHP parsing written in C?
P. S. Journal 3.2 failed with OpenTwig (
Users browsing this forum: lockiedownunder and 6 guests