I have a new project in which MODX handles two areas: Agenda/Cursus for booking dates and Commerce for selling products.
I use Fenom as the template engine for the sites in the basic version. This works very well with Agenda/Cursus, and the need for chunks and snippets in the database is minimal.
However, for the E-mail templates i need to use the classic MODX template engine. For the shop, Commerce brings the Twig template engine (as Fred also did).
This is not so important, but it needed to be listed. For a custom CMP, Smarty is basically the template engine. However, I want to write a CMP in the future that doesn’t use Smarty or ExtJS. I will only use Fenom and AlpineJS Ajax in future.
At least there are three template engines. I think using Twig for all the things listed above would be great.
A few years ago, there was a plugin that brought Twig to MODX, and Commerce/Fred also uses Twig. And when I remember right, ContentBlocks 2 will also support Twig. Here is also an old topic an that.
So here are my questions:
Are there any plans to make Twig a viable alternative to the MODX/Fenom template engine?
What problems need to be solved?
Who else would like to see this feature? And could this be funded through crowdfunding?
I got so far last autumn through writing a very simple Extra for MODX3 to add Twig support. It works, but needs further testing. It takes a different approach to Fenom and the earlier plugin, in that it parses chunks before they are included into the main template, which worked well for me.
My motivation came after working on a couple of sites that used Fenom extensively. I experienced too many white screens of death because of the Fenom parser picking up JSON or JS in the templates. In places I had to base64encode data to pass it between child and parent chunks, else Fenom broke it!
And so this code was born.
I’ve submitted a ContentBlocks patch to Mark to let Twig (and any other parser) be used in ContentBlocks templates, but it hasn’t made it into a release.
If others are interested I’ll update the branch and add some documentation. I have a test site I was using to make sure it worked so I should be able to include examples.