Slim: Update Twig-view / PHP-View

Created on 20 Nov 2016  路  4Comments  路  Source: slimphp/Slim

  • Need to update Twig/PHP -view for 4.x
Slim 4

Most helpful comment

Hello @geggleto, @codeguy
It would be nice to have a View template renderer interface and a different signature for the render method:

public function render($template, array $data = []);

I believe that a template renderer should not be aware of nor interact with Psr\Http\Message\ResponseInterface.
The response can be written to directly inside middleware using the response interface methods. Something like this:

return $response->write(
    $this->view->render('/my/template/file.phtml', [
        //..key=>value pairs here
    ]);
);

//or

return new HtmlResponse($this->view->render('/my/template/file.phtml', [/*...*/]);

kind regards

All 4 comments

No description provided. ?

Suggest add array to items collection
https://github.com/slimphp/Twig-View/pull/66
need to collect items from different classes that not have Response
not important as it will be called offsetAdd or addGlobal or like on another

Hello @geggleto, @codeguy
It would be nice to have a View template renderer interface and a different signature for the render method:

public function render($template, array $data = []);

I believe that a template renderer should not be aware of nor interact with Psr\Http\Message\ResponseInterface.
The response can be written to directly inside middleware using the response interface methods. Something like this:

return $response->write(
    $this->view->render('/my/template/file.phtml', [
        //..key=>value pairs here
    ]);
);

//or

return new HtmlResponse($this->view->render('/my/template/file.phtml', [/*...*/]);

kind regards

Issues need to be opened on relevant repositories for Slim 4 updates.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

derekjones picture derekjones  路  19Comments

l0gicgate picture l0gicgate  路  28Comments

Sam-Burns picture Sam-Burns  路  53Comments

boosis picture boosis  路  25Comments

akrabat picture akrabat  路  43Comments