I have a Twig template (.html file) that I want to render (replace the tokens with values from my PHP file). Instead of sending the rendered result to a browser, however, I want to write it to a new .html file. I would imagine the solution would also be similar for a Django template.
How can I do this in PHP?
You can get the rendered output assigned to a variable and then do with it what you please.
$bob = $this->render('MyBundle:index.html.twig',[
'foo' => $foo,
'token' => $token
]);
dump($bob->getContent());exit(0);