in reply to Variable include names in HTML::Template

Perhaps turn the problem inside out.

If the header, sidebar and footer is static across your templates you could put all that html in a "master" template and have the variable content as a TMPL_VAR. You would then run HTML::Template twice. Once to create the content, populating any params as appropriate, and then supply that to the "master". The heavy lifting is done by your code and you leave HTML::Template to worry about what it looks like.

Any site wide changes, such as adding an additional wrapper around the content (and you can never have too many wrappers imo) would then only need to be added to the "master". You can have a complete site redesign by changing one template and there would then be no need to trouble any of the individual "content" templates. I've learnt at great cost that is a very good thing indeed.

Slightly more work perhaps but I think the flexibility/maintainability it buys you is well worth it.

Replies are listed 'Best First'.
Re^2: Variable include names in HTML::Template
by dsheroh (Monsignor) on Mar 03, 2008 at 17:38 UTC
    Thanks for the suggestion! That's exactly what I wanted to accomplish (whether I explained it clearly or not), but having HTML::Template itself handle both passes hadn't occurred to me.

    I doubt that it would take more than one or two site-wide changes to more than make up for the extra work involved in setting it up. (Plus one extra site-wide change in my case, since I'll need to make a site-wide change in the process of doing so...) And how many sites go their entire lifetime with only one or two site-wide changes?