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.