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