in reply to HTML::Template - what's the rule of thumb?

I generally have one template family for each CGI script. (I use HTML::Template, PDF::Template, Excel::Template, and Graph::Template in conjunction with one another. Thus, there are four templates, each describing a different output format for the same layout.) Sometimes, two scripts will share a template, if the same layout is used, but with different calculations. Sometimes, a script might have more than one layout, depending on what it might do (though that's very rare and should, IMHO, be avoided). But, 1-1 is my most common thing.

Now, <TMPL_IF>'s are not all bad, but if you start having a bunch of them, and they're unrelated, you should probably break it out into a bunch of templates, using <TMLP_INCLUDE>'s and make things easier on yourself. Remember - you should be separating display from logic. If you need to have a bunch of display-logic in your logic, you haven't really made things easier on yourself, have you?

------
We are the carpenters and bricklayers of the Information Age.

Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

  • Comment on Re: Template::HTML - what's the rule of thumb?

Replies are listed 'Best First'.
Re: Re: Template::HTML - what's the rule of thumb?
by kiat (Vicar) on Dec 18, 2003 at 14:30 UTC
    Thanks, dragonchild

    But, 1-1 is my most common thing ... Remember - you should be separating display from logic. If you need to have a bunch of display-logic in your logic, you haven't really made things easier on yourself, have you?
    That's reassurring to hear. I'm kinda facing a dilemma deciding on how best to use a template - a decision between having a template serving a couple of different outputs (hence, requiring possibly some display logic in the template) and being more generous in the creation of templates for different outputs.

    It's a delicate trade-off, no doubt. While it makes good sense to have similar outputs share the same template, trying to push things to the limit will only make easy things difficult (which is so unperlish :))

    I'll remember this when I remember one of perl's virtues: Easy things should stay easy.