protected function _render()
    {
        $response = $this->_application->response;
        $body = $response->getBody();
        $this->_controller->set(
            'flashMessages', $this->_controller->flashMessages
        );
        $data = $this->_controller->getViewVars();

        $doLayout = $this->_controller->renderLayout && $this->getLayout();
        $doView = $this->_controller->renderView && $this->getView();

        try {

            if ($doView) {
                $body = $this->getView()
                    ->set($data)
                    ->render();
            }

            if ($doLayout) {
                $body = $this->getLayout()
                    ->set('layoutData', $body)
                    ->set($data)
                    ->render();
            }

        } catch (\Exception $exp) {
            throw new Exception\RenderingErrorException(
                "Error while rendering view: " . $exp->getMessage()
            );
        }

        return $response->setContent($body);
    }