Is there a way to disable the Twig compilation cache for a particular template?
I\'m using Twig for my email templates. When someone updates these templates, they ar
I think your answer might be not in disabling cache for a specific template, but clearing the cache for a template after it's been updated. I haven't tested the code below, but it seems reasonable. Play around with it a bit
In your action/service that saves a template (after the template has been saved):
$fileCache = $this->container->get('twig')->getCacheFilename('AcmeDemoBundle:Default:index.html.twig');
if (is_file($fileCache)) {
@unlink($fileCache);
}
For more information, check out how twig cache files are handed in /vendor/twig/twig/lib/Twig/Environment.php (\Twig_Environment) -- method loadTemplate().