protected function renderResponse(string $name, array $variables = [], ResponseInterface $response = null): ResponseInterface
    {
        // Create new Response object if not given in parameter
        if (is_null($response)) {
            $response = new Response;
        }

        // Remove all headers
        header_remove();

        // Rendering
        $rendering = $this->render($name, $variables);

        // Get all headers defined in template engine and add to response
        foreach (headers_list() as $header) {
            $header = explode(':', $header, 2);
            $response = $response->withAddedHeader($header[0], $header[1] ?? '');
        }

        // Get body of response
        if ($response->getBody()->isWritable()) {
            $response->getBody()->write($rendering);
        } else {
            $body = new Stream;
            $body->write($rendering);

            $response = $response->withBody($body);
        }

        return $response;
    }