I am trying to render a template with my controller but does not work it show me this error :
LogicException: The controller must return a response (
Hello Bob!
given). in Symfony\Component\HttpKernel\HttpKernel->handleRaw() (line 163 of core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernel.php).
My function :
public function helloAction($name) {
$twigFilePath = drupal_get_path('module', 'acme') . '/templates/hello.html.twig';
$template = $this->twig->loadTemplate($twigFilePath);
return $template->render(array('name' => $name));
}
In Drupal 8 you either return a Response object or a render array from a controller. So you have two options:
1) Place the rendered template into a Response object:
2) Place the rendered template into a render array: