$twig = new Twig_Environment(new Twig_Loader_String());
$rendered = $twig->render(
"Test string template: {{ result }}",
array("result" => "Success!")
);
// Instead of
$view->render($response, 'template.twig', []);
// Use
$content = $view->fetch('template.twig', []);
// It will not be added to a response,
// just saved as a string in the variable!
$twig = clone $this->get('twig');
$twig->setLoader(new Twig_Loader_String());
$rendered = $twig->render(
"Test string template: {{ result|humanize }}",
array("result" => "mega_success")
);