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; );
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Two questions about HTML::Template
by Cody Pendant (Prior) on Jun 23, 2006 at 21:17 UTC | |
Re^2: Two questions about HTML::Template
by bradcathey (Prior) on Jun 10, 2007 at 00:49 UTC |
In Section
Seekers of Perl Wisdom