[Templates] CGI/TT vs SSI

Eric Siegerman erics@telepres.com
Wed, 8 Oct 2003 14:58:06 -0400


On Wed, Oct 08, 2003 at 02:29:36PM +0200, Tosh Cooey wrote:
> Hi, I'm currently using a mix of static HTML and TT driven CGI.
> 
> I want to streamline some things, especially using a standard menu based on an 
> XML file.
>
> [Two approaches:
>   1. put SSI's in both static HTML and templates
>   2. turn the static HTML into templates, in order to be able
>      to use "[% PROCESS menu %]" in them
> ]

I'm pretty new to TT, so if I say something dumb, please correct
me gently :-)

I can think of some other approaches:
 3. Truly six-of-one-half-dozen-of the other: Use SSI's in the
    static pages, but PROCESS directives in the templates:

	.html
	<html>
	stuff...
	<!--#include virtual="/menu.cgi" -->
	</html>

	.tt/.cgi
	<html>
	stuff...
	[% TTfun %]
	[% PROCESS menu %]
	</html>

    Pro: You get the best of both worlds
    Con: You have to implement the menu engine twice: as CGI and
	 as TT template


 4. Preprocess the menu into static HTML, as Leo suggested.

    Pro: More efficient than (3) -- the static pages only involve
         SSI's, not CGI's
    Con: As you noted, that static preprocessing has to be done
         after every change


 5. Turn the static pages into templates, as in (2), but then
    preprocess them back into static HTML with ttree or custom
    Perl.

    Pro: Even more efficient:  you can do away with SSI's
	 completely for the static pages; they're now served as
	 straight disk files

    Con: Even more static preprocessing.  Not necessarily more
	 steps for the human involved, but a longer "make" run,
	 and it has to be done after *every* change to the
	 (no-longer-static) HTML pages, not just after menu
	 changes


(3) seems cleaner in one sense, in that it handles each class of
file in the "natural" way, without imposing the processing
appropriate to the other class, as both (1) and (2) do.  And if
you implement the CGI script in terms of TT, the disadvantage
isn't as bad as it looks at first.

I'm not sure about (4).  Without mod_perl, I imagine it'd be a
clear win.  But with mod_perl, is that still the case?  (I
suppose that depends largely on how used one is to typing "make"
as part of one's test cycle :-)

I'm even less sure about (5).  The effiency gain -- eliminating
SSI processing -- seems fairly minimal.  How much of a win is
that in practice?

--

|  | /\
|-_|/  >   Eric Siegerman, Toronto, Ont.        erics@telepres.com
|  |  /
When I came back around from the dark side, there in front of me would
be the landing area where the crew was, and the Earth, all in the view
of my window. I couldn't help but think that there in front of me was
all of humanity, except me.
	- Michael Collins, Apollo 11 Command Module Pilot