On Thu, 8 Jun 2000, Greg Cope wrote:
> This may be veering off topic - but its been on my mind for a while now ....
>
> Apart from thanking Stas for his benchmark work, which I find very
> interesting (does he sleep ;-) - this and few few others (benchmarks) have
> all touched on the area of including mod_perl output within HTML. I have
> always wonder what everyone else is doing on this front.
>
> I usually suck a template into memory (one long line) - usually done at
> startup. I then create all the conent with either pushing onto an array, or
> .= string concatination. Finally I regex the template - looking for my tags
> and replave those with output. Needless to say that one page can onsists of
> many templates (page or inside of table (bits from <tr> </tr>) etc ...).
>
> From Stas previous benchmarks I've preloaded the mysql driver and now
> usually use the "push" onto array to prepare content - Thanks Stas.
>
> Who does everyone else do it ? Can this type of operation (that everyone
> must do at some time) be optimised as aggressively as some of the others ?
> Yet still keep the abstraction between design and content.
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.
Of course I don't know if its the fastest possible method - I prefer to
code cleanly first and worry about performance later. Much later. Clean
code tends to lend itself to better performance in the long run anyway,
because it's easier to optimise serious performance problems away.
--
<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