http://qs321.pair.com?node_id=557229


in reply to Two questions about HTML::Template

in HTML::Template, the includes are processed when the template is parsed, and the variables and if statements are interpolated when the template is processed. So your includes all have to exist, and they will all be loaded and parsed regardless of any if statements around them.

When you want to change the template that is included based on a decision in the code, I often find it easier to change the include path that HTML::Template uses, and then use the same include file name in your template. By changing the include path. HTML::Template will look in a different place for the include file when the template is parsed. Here is some psuedo code to illustrate it:

my @path; if ($foo) { push @path, '/foo'; } else { push @path, '/bar'; } push @path, '/standard_templates'; my $template = HTML::Template->new( filename => 'file.tmpl', path => \@path; );