diff options
author | elliott_c <ocielliottc@users.noreply.github.com> | 2011-12-05 15:17:43 +0000 |
---|---|---|
committer | elliott_c <ocielliottc@users.noreply.github.com> | 2011-12-05 15:17:43 +0000 |
commit | 13768a365c17b1302524b74fcbf550b953f434cf (patch) | |
tree | 5e3748e8cb5c46bf3f19c92b8d3e04001798ea3f /modules/TemplateParser.pm | |
parent | 483cc9caf2d4c6a974bc53570e4b6dd4952cdf0f (diff) | |
download | MPC-13768a365c17b1302524b74fcbf550b953f434cf.tar.gz |
ChangeLogTag: Mon Dec 5 15:17:04 UTC 2011 Chad Elliott <elliott_c@ociweb.com>
Diffstat (limited to 'modules/TemplateParser.pm')
-rw-r--r-- | modules/TemplateParser.pm | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/modules/TemplateParser.pm b/modules/TemplateParser.pm index 0b3e07ca..83eb7065 100644 --- a/modules/TemplateParser.pm +++ b/modules/TemplateParser.pm @@ -310,8 +310,8 @@ sub get_value { my $value; my $counter = $self->{'foreach'}->{'count'}; my $fromprj; - my $scope; - my $sname; + my @scopes; + my @snames; my $adjust = 1; ## $name should always be all lower-case @@ -319,14 +319,11 @@ sub get_value { ## First, check the temporary scope (set inside a foreach) if ($counter >= 0) { - ## Find the outer most scope for our variable name - for(my $index = $counter; $index >= 0; --$index) { - if (defined $self->{'foreach'}->{'scope_name'}->[$index]) { - $scope = $self->{'foreach'}->{'scope_name'}->[$index]; - $sname = $scope . '::' . $name; - last; - } - } + ## Create a list of possible scoped names + @scopes = reverse @{$self->{'foreach'}->{'scope_name'}}; + @snames = map { $_ . '::' . $name } @scopes; + push(@snames, $name); + while(!defined $value && $counter >= 0) { $value = $self->{'foreach'}->{'temp_scope'}->[$counter]->{$name}; --$counter; @@ -338,6 +335,9 @@ sub get_value { $value = $self->{'values'}->{$name}; } } + else { + @snames = ($name); + } if (!defined $value) { if ($name =~ /^flag_overrides\((.*)\)$/) { @@ -353,8 +353,7 @@ sub get_value { if (!defined $value) { ## Calling adjust_value here allows us to pick up template ## overrides before getting values elsewhere. - my $uvalue = $self->{'prjc'}->adjust_value([$sname, $name], - [], $self); + my $uvalue = $self->{'prjc'}->adjust_value(\@snames, [], $self); if (defined $$uvalue[0]) { $value = $uvalue; $adjust = 0; @@ -404,7 +403,7 @@ sub get_value { ## Adjust the value even if we haven't obtained one from an outside ## source. if ($adjust && defined $value) { - $value = $self->{'prjc'}->adjust_value([$sname, $name], $value, $self); + $value = $self->{'prjc'}->adjust_value(\@snames, $value, $self); } ## If the value did not come from the project creator, we @@ -425,7 +424,8 @@ sub get_value { } } - return $self->{'prjc'}->relative($value, undef, $scope); + return (defined $value ? + $self->{'prjc'}->relative($value, undef, \@scopes) : undef); } |