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;
    }
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;
    }
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 ; }
Do render of templates in Response object.

@param string                                   $name      Filename of template
@param mixed[]                                  $variables Variables for template
@param \Psr\Http\Message\ResponseInterface|null $response  Response object to complete

@return \Psr\Http\Message\ResponseInterface
@throws \Berlioz\Core\Exception\RuntimeException if application not accessible
Do render of templates in Response object .