I\'d like to know if it\'s possible to have {filename}.html
generated for every {filename}.html.twig
? I know one solution is to copy and paste the sour
If you want to create these file automatically with each render, then I suggest to overwrite the default render method of the Twig_Environment
and create an instance of your custom class to init Twig
class MyTwigEnvironment extends \Twig_Environment {
public function render($name, array $context = array())
{
$html = $this->loadTemplate($name)->render($context, $site_id);
file_put_contents('path/to/cache/folder'.$name.'.twig', $html);
chmod('path/to/cache/folder'.$name.'.twig', 0664);
return $html;
}
}
$twig = new MyTwigEnvironment($loader, $options);
echo $twig->render('some_template.html');