I too, have used two template objects to solve this problem:
use strict; use warnings; use HTML::Template; use Inline::Files; my $skeleton = HTML::Template->new(filehandle => \*SKELETON); my @page = ( HTML::Template->new(filehandle => \*PAGE1), HTML::Template->new(filehandle => \*PAGE2), ); for (@page) { $skeleton->param(body => $_->output); print $skeleton->output; } __SKELETON__ <html> <body> <tmpl_var body> </body> </html> __PAGE1__ hello world __PAGE2__ foo bar baz qux
But, these days i prefer to use Template with it's ultra handy WRAPPER construct. I am sure that Template essentially has to do the same thing: load a seperate template and substitute values, but it does it for me. :) For example, all i need to do is create the skeleton (i'll call it skeleton.html)
<html> <head> <title>[% title %]</title> </head> <body> [% content %] </body> </html>
And some pages:
(page1.html) [% WRAPPER skeleton.html title="Page 1" %] hello world [% END %] ----------------------------------------------- (page2.html) [% WRAPPER skeleton.html title="Page 2" %] foo bar baz [% END %]
And i'm done. :)

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

In reply to Re: HTML::Template question. by jeffa
in thread HTML::Template question. by jdtoronto

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.