vmoulin78 / codeigniter-layout-library

CodeIgniter Template Library
MIT License
24 stars 9 forks source link

Fix render_view() for use CI Output Class #4

Closed albertone closed 6 years ago

albertone commented 6 years ago

Change render_view() for use CI Output Class instead echo. This change allow use pseudo variables by default such as {elapsed_time}. It's related to #3

vmoulin78 commented 6 years ago

Hello Albertone,

As we can see in the doc: https://www.codeigniter.com/userguide3/libraries/output.html I think that the set_output() method should be used in a very specific context and the use of this method could trigger some weird behaviors

If you want to display "elapsed_time", instead of {elapsed_time}, you can write: echo $this->benchmark->elapsed_time();

Vince

albertone commented 6 years ago

Hi @vmoulin78,

I was reading the warning about set the output manually; the warning also says that must be the last thing in the controller like the library does, and therefore the controller does too.

Another option that we have is use the method append_output() because when the actual echo $output; the $output from Output Class is null. This method has not any warning about his use.

The purpose for preserve the use the Output Class instead of the echo, as well as use benchmarking pseudovariables, is use the caching system because Output Class is also responsible for caching the web pages.

About use echo $this->benchmark->elapsed_time(); I tried but I can´t get show the result. When I use it, it display literally {ellapsed_time}. How are you use it?

Thank you for your attention.

About use echo $this->benchmark->elapsed_time(); I tried but I can´t get show the result. When I use it, it display literally {ellapsed_time}. How are you use it?

Thank you for your attention.

vmoulin78 commented 6 years ago

Hi Albertone, I will do some tests about the different methods of the Output library. Vince

vmoulin78 commented 6 years ago

Hi Albertone, I modified the library. Now, it works. Vince