On Thu, 8 Jun 2000, Richard L. Goerwitz wrote: > > As far as I've seen, the fastest template systems are the ones that > > convert the template to Perl code. So that's what I do. The templates all > > call a method (in my case $Response->Write()) which appends to a > > string. If there are no exceptions (see the guide) the string is sent to > > the browser. If there are exceptions, I parse/send an error template with > > the error in the template. > > I'm trying to follow this explanation, but can't quite visualize what > you're doing. I wonder if you could perhaps post a code fragment to the > list elucidating... Err... It's a bit complicated. I'm porting someone else's template system from a VB environment, and it's not pretty, but basically I have a response class with a Write method that looks like this: sub Write { my $self = shift; $self->{output} .= join('', @_); } I then have templates that get turned from this: <html><title><xx-mytag></title></html> Into the following Perl code: sub handler { my ($Response, <otherobjects>, $__params) = @_; $Response->Write(q|<html><title>|); $Response->Write($__params{'xx-mytag'}); $Response->Write(q|</title></html>|); } And then my handler looks like: sub handler { my $r = shift; # setup $Response, etc... ... eval { do_stuff(); } if ($@) { if ($@->isa('Foo')) { # process foo exception } elsif ($@->isa('Bar')) { # process bar exception } elsif ($@->isa('Error')) { # error $db->rollback(); Template->Output('error.html', text => $@->{error}); } } $db->commit; $Response->Send; return OK; and do_stuff() calls: Template->Output('templatefilename', %params); But if it errors out for some reason (db fails, etc) then it gets trapped by the exception handler, and instead of giving a 500 internal server error, we get an nice error page which they can take massive .bmp screen shots of and mail to their sysadmin over a 56k connection ;-) See the guide for the exception handling class I use (or variant of). -- <Matt/> Fastnet Software Ltd. High Performance Web Specialists Providing mod_perl, XML, Sybase and Oracle solutions Email for training and consultancy availability. http://sergeant.org http://xml.sergeant.org