You can call setFormat('html')
on the view in your controller action.
For example to only render and return a template:
class AcmeController extends FOSRestController
{
public function getAction()
{
// ...
$templateData = [
'some' => $vars,
];
$view = $this->view(null, 200)
->setFormat('html')
->setTemplate("AcmeBundle:Tpl:some.html.twig")
->setTemplateData($templateData);
return $this->handleView($view);
}
}
But then the view handler will always try to render a template. If you don't need to render because you already have your html, just return a new symfony response with the correct headers:
class AcmeController extends FOSRestController
{
public function getAction()
{
// you already have $html
$headers = ['Content-Type' => 'text/html; charset=UTF-8'];
return \Symfony\Component\HttpFoundation\Response::create($html, 200, $headers);
}
}