in reply to Dynamic TMPL_INCLUDE in HTML::Template

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