echoing TT fix into H::T::E for variable renaming

This commit is contained in:
Colin Kuskie 2007-01-25 17:59:24 +00:00
parent 443c5cf405
commit 4285ee1e9c
2 changed files with 16 additions and 14 deletions

View file

@ -1,4 +1,5 @@
7.3.8 7.3.8
- Fixed a template variable rewriting problem with HTML::Template::Expr
- Added a attachment_thumbnail option to the CS RSS feed. - Added a attachment_thumbnail option to the CS RSS feed.
7.3.7 7.3.7

View file

@ -21,21 +21,22 @@ use HTML::Template::Expr;
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub _rewriteVars { # replace dots with underscrores in keys (except in keys that aren't usable as variables (URLs etc.)) sub _rewriteVars { # replace dots with underscrores in keys (except in keys that aren't usable as variables (URLs etc.))
my $vars = shift; my $vars = shift;
foreach my $key (keys %$vars){ my $newVars = {};
my $newKey = $key; foreach my $key (keys %$vars){
$newKey =~ s/\./_/g if $newKey !~ /\//; my $newKey = $key;
if(ref $vars->{$key} eq 'HASH'){ $newKey =~ s/\./_/g if $newKey !~ /\//;
$vars->{$newKey} = _rewriteVars($vars->{$key}); if ( ref $vars->{$key} eq 'ARRAY') {
delete $vars->{$key} if($key ne $newKey); foreach my $entry (@{$vars->{$key}}) {
}else{ push(@{$newVars->{$newKey}}, _rewriteVars($entry));
if($key ne $newKey){
$vars->{$newKey} = $vars->{$key};
delete $vars->{$key};
} }
} } elsif(ref $vars->{$key} eq 'HASH') {
} $newVars->{$newKey} = _rewriteVars($vars->{$key});
return $vars; } else {
$newVars->{$newKey} = $vars->{$key};
}
}
return $newVars;
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------