All I did was to create my own FillTemplate subroutine that took as parameters:

header => 0|1
defaults to true
footer => 0|1
defaults to true
tmpl => $filename
required parameter
params => {...}
any parameters that need passing to HTML::Template
and others. In my case, header would include the <html><head> and <div id="content> from your example, so that the actual template would only be the actual content. I even had flags for post-processing (e.g., I had a post-processing function that would parse the whole output as XML, and then go in and mark up tables such that headers would be repeated every x rows, and alternating data rows would get alternating backgrounds to make it a bit easier to read). And then all this would be concatenated and returned from the function, just like HTML::Template does.

Depending on your needs, you could have multiple headers as parameters, each with an appropriate default. Whenever I found myself doing something over and over again, it got folded into a parameter to FillTemplate. Admittedly, Template-Toolkit changes all this - I can use blocks to do the same things, with more flexibility, and more explicitly, though it also makes my templates more verbose.


In reply to Re: Variable include names in HTML::Template by Tanktalus
in thread Variable include names in HTML::Template by dsheroh

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.