On 28.10.2009, at 22:53, Nestor A. Diaz wrote:

Hello, i want to know if there is any possibility to disable the output of the rendering template when an exception occurs, right now processing stop if there is any exception but the page is shown until the error was made, i use the execute method, not the echoExecute, which is supposed not to output the document.

I need to create a webpage that is going to be send by email, not to display on the web browser, if the templates throws an exception i can catch it, but i don't want it to be displayed truncated on the web browser, is there any way to disable this behavior ?

Hm, execute() uses buffering already, so it shouldn't output anything... unless you get a fatal error during execution of the template. In that case PHP takes over and outputs PHPTAL's buffer anyway. Only fatal errors (mostly invalid syntax in php: or your custom modifiers if you have any) could be problematic, regular errors (unclosed tags, missing variable) should always end cleanly.

Does catching of exceptions help?

try {
catch(PHPTAL_Exception $e) {
// do whatever you'd do when template fails, $e->getMessage() will give you the error.

If not, then try:

function on_die_handler($output)
 global $can_output;
 if ($can_output) return $output; else return '';




regards, Kornel

PHPTAL mailing list

Reply via email to