Most template solutions have minimal built in logic to differ output based on program input. (or least I know that Template Toolkit does for sure). However, I only do this when the change is subtle with the overall page keeping much of the same layout; insted it's usually easier to write two different template files if the change is more drastic. Note that still cleans up your perl code, more so than writing two branches of CGI.pm HTML functions.
But templates are not always the solution in every case. If you have a SSI included script, for example, you only need the minimal HTML that CGI provides. Short, demonstration scripts that aren't really part of a site could easily qualify as well. In addition, if you are building a page that has to be speedy (maybe it's your home page of a million+ hits per day site), a template solution could just slow you down, though if the rest of the site is in template form, it's a tossup. (In general in this situation, your 'entrance' page ought to be statically delievered, which might mean you need to create it every 5 minutes or so from dynamic content).
But if you are building a site of any magnitue more than a handful of pages, you really ought to be considering templates as to avoid problems with consistent site look after a time.
Dr. Michael K. Neylon - mneylon-pm@masemware.com
||
"You've left the lens cap of your mind on again, Pinky" - The Brain
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
|
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.