Grabbing Symfony TWIG template output as a string to use in string-based HTML bodies such as email templates, etc.
Amazing, but this solution is so simple and it is no where on Stack Overflow. There’s a lot more documentation about rendering templates from a string but not TO a string, something very helpful if you want to use templating to build html output for things like email templates.
$output=$this->render('view.html.twig', array(
'form' => $form->createView(),
'info' => $info,
‘otherVals’ => $otherVals,
‘someArray’=> $someArray
));
var_dump($output->getContent()); exit;