I'm wondering if you could process a template twice to achieve what you want. For example, on the first pass, HTML::Template will parse this code:
<TMPL_VAR name="include_link">
by passing
include_link => qq/<TMPL_INCLUDE name="$custom_link">/ to the param() method of your template object. So, considering for example that your $custom_link is set to 'foo_page.html', the initial template should be parsed into this:
<TMPL_INCLUDE name="foo_page.html">
Then, you simply have to use this parsed output to initialize yet another template object and 'reparse' it the last time to get exactly what you want.
I'll try to build a little sample script for you to look at in the mean time ;-)
UPDATE: here's some sample code implementing what I was just talking about:
main script:
use strict;
use HTML::Template;
my $tmpl = new HTML::Template(
filename => 'first.tmpl'
);
# generate custom page link...
my $custom_page = "second.tmpl";
# inject a custom piece of Template code
$tmpl->param(special_page_include => qq/<TMPL_INCLUDE name = "$custom_
+page">/);
# process custom built template..
my $tmpl_final = new HTML::Template(scalarref => \$tmpl->output());
print $tmpl_final->output();
first.tmpl
Including custom page...
<TMPL_VAR name = "special_page_include">
-----------
rest of the page
second.tmpl
SECOND PAGE!
script output (test run):
Including custom page...
SECOND PAGE!
-----------
rest of the page
|
"There is no system but GNU, and Linux is one of its kernels." -- Confession of Faith
|
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.