If I ask Twig to render example.twig
it will generate a cache file named something like 8e8456gffc99c672976eff.php
(if cache is enabled).
Is there a way to then take 8e8456gffc99c672976eff.php
, and make Twig run it directly without even having access to the original example.twig
file?
I want something like $this->twig->renderCache('8e8456gffc99c672976eff.php', $data);
but haven’t found a straightforward way to do it (I can hardcode it but would prefer a generalized solution).
Edit: Current solution (for 1.x at least) is to init Twig, include_once
the php cache file, call render and in Twig_Environment::loadTemplate
simply overwrite the template class name.
The barely generalized solution is to do $cls = '__TwigTemplate_' . str_replace('.twig', '', $name);
so that I don’t have to hardcode the name in there, only change the class name in the cache file.
However, I’d prefer a solution that doesn’t require any changes to Twig itself.
3