In my controller I want to return Drupal\Core\Render\HtmlResponse, and also I want to take HTML content from the template. The problem is that if I will try to render() a rendereable array before returning HtmlResponse - I'm getting "The website encountered an unexpected error. Please try again later." error. Array is being rendered correctly when I will just return it as it is, but with all Drupal HTML, which I don't want. What am I doing wrong?

Added #1: Discovery - all works well when I return Zend\Diactoros\Response\HtmlResponse . Now I'm even more confused. Why is that?

Added #2: When I use "renderPlain()" renderers method it also works, but I'm not sure of drawbacks yet.


Oh, I believe I should use "renderRoot()" method of renderer in case where I'm rendering HTML for response just to be send. Please correct me someone if I'm wrong.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.