use HTML::Template::Compiled compatible => 1;
my $tmpl_str1 = q|<tmpl_switch language>
<tmpl_case de>echt cool
<tmpl_case en>very cool
<tmpl_case es>superculo
<tmpl_case fr,se>don't speak french or swedish
<tmpl_case default>sorry, no translation for cool in
language <%=language%> available
<tmpl_case>(same as default)
</tmpl_switch>|;
my $tmpl_str2 = q|<tmpl_switch language>
<tmpl_case de>echt cool
<tmpl_case en>very cool
<tmpl_case es>superculo
<tmpl_case fr,se>don't speak french or swedish
<tmpl_case default>same as default)
</tmpl_switch>|;
my $t1 = HTML::Template::Compiled->new(scalarref
=>\$tmpl_str1 );
my $t2 = HTML::Template::Compiled->new(scalarref
=>\$tmpl_str2 );
print 'T1:'.join(', ', $t1->param())."\n";
print 'T2:'.join(', ', $t2->param())."\n";
use CGI;
my %def_val = ( language => 'en' );
foreach my $key ( $t1->param() ){
$t1->param( $key, CGI::param($key)||$def_val{$key} );
};
foreach my $key ( $t2->param() ){
$t1->param( $key, CGI::param($key)||$def_val{$key} );
};
print "T1:\n".$t1->output()."\n\n";
print "T2:\n".$t2->output()."\n\n";
Logged In: NO
Function param() detected only <tmpl_var> tags and not
detected tags <tmpl_switch>