Re: Default tag handler

From: Date: Tue, 25 Sep 2001 07:52:39 +0000
Subject: Re: Default tag handler
References: 1 2  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-1541@lists.php.net to get a copy of this message
Monte Ohrt wrote: > Anders Janson wrote: > > > > Monte Ohrt wrote: > > >>When would you want to use a template function that doesn't exist? > > > > Well, I can not give any example of that :) > > But sometimes my templates are edited online. The preview looks really > > ugly if template tags are misspelled! A default handler could catch > > what went wrong, and bring up the editor page again. Or refuse to > > save the edited version into the database/file system. Or... > > Today, the application does not really know if the compiler failed. > > > > I'm not sure how you would handle this at compile time. Bringing up the > edit page with a default error handler sounds a bit messy. My idea was to use "$template->fetch('foo.tpl')", and let the default handler register as much info as possible, and let the compiler continue as fas as it possibly could if there are any problems. After that I could check some status parameter or whatever. But even if the compiler is compiling a template without errors, PHP might very well crash on the generated code. So I guess I would not win much having a default handler. Not in this case. > > > > >>I think that you would WANT an error. > > > > Monte, nobody wants errors ;) > > Seriously, what I would find useful is a way to DETECT the error. > > And handle it gracefully. > > It already does :-) The compiler triggers a PHP error, telling you > _exactly_ what the error was, and where it can be found. Now the beauty > of Smarty using the PHP error handler is that you can write a custom PHP > error handling function in your application. You don't like to see them > dumped out on the screen where the error is happening? Write a function > that does something else with it. Smarty doesn't need to know how you > are handling these. Could be a possible way, but still messy. :-) /Anders

« previous php.smarty.general (#1541) next »