I have a Symfony project which also sends some standard emails like "Dear user XYZ, please find the attached file" etc. - the content of these emails is stored in Twig-templates like yourfile.html.twig. The admin has the ability to change those basically "text-files" in a simple webinterface. Any changes are written back to the file. The emails are send with SwiftMailer just like in the example code in their docs with the filepath to the twig template.
This works fine in the debug environment - as Twig automatically rerenders cached files which were changed. However, when I am in production environment this doesn't work anymore. Changes made to the mail template aren't recognised by Twig and it uses the cached version (and the user therefore gets an email with the text of the old version).
One way to solve this problem would be to just clear the cache every time the admin changed the email templates (which won't happen too often). Anyway, I don't like this way as it forces a full rerender of every page which is just a waste of resources...
Another possibility would be to enable the "auto rerender" feature of Twig also in production environment, but again I'm not happy with this solution as it results in performance loses...
The "best" way of doing this would be to call some function to rerender just this one file which was changed (Pseudo code: twig->rerender("path/to/file/yourfile.html.twig")), but I could not find any way to accomplish this. Maybe I just used the wrong keywords for searching?
I would really appreciate if someone has an idea on how to solve the problem above!
Thanks in advance, katze_sonne