Changeset 1926 for branches/release-35/lib/MT/Template/ContextHandlers.pm
- Timestamp:
- 04/16/08 10:50:21 (20 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
branches/release-35/lib/MT/Template/ContextHandlers.pm
r1911 r1926 1324 1324 my $vars = $ctx->{__stash}{vars} ||= {}; 1325 1325 my $glue = $args->{glue}; 1326 $glue = '' unless defined $glue;1327 1326 my $var = $args->{var}; 1328 1327 for (my $i = $start; $i <= $end; $i += $incr) { … … 1336 1335 my $res = $builder->build($ctx, $tokens, $cond); 1337 1336 return $ctx->error($builder->errstr) unless defined $res; 1338 if ($res ne '') { 1339 $out .= $glue if $cnt > 1; 1340 $out .= $res; 1341 $cnt++; 1342 } 1337 $out .= $glue 1338 if defined $glue && $cnt > 1 && length($out) && length($res); 1339 $out .= $res; 1340 $cnt++; 1343 1341 } 1344 1342 return $out; … … 1590 1588 my $vars = $ctx->{__stash}{vars} ||= {}; 1591 1589 my $glue = $args->{glue}; 1592 $glue = '' unless defined $glue;1593 1590 foreach my $item (@$var) { 1594 1591 local $vars->{__first__} = $i == 1; … … 1625 1622 return $ctx->error($builder->errstr) unless defined $res; 1626 1623 if ($res ne '') { 1627 $out .= $glue if $i > 1;1624 $out .= $glue if defined $glue && $i > 1 && length($out) && length($res); 1628 1625 $out .= $res; 1629 1626 $i++; … … 1916 1913 my $tokens = $ctx->stash('tokens'); 1917 1914 my $needs_entries = (($ctx->stash('uncompiled') || '') =~ /<MT:?Entries/i) ? 1 : 0; 1918 my $glue = $args->{glue} || '';1915 my $glue = $args->{glue}; 1919 1916 my $res = ''; 1920 1917 local $ctx->{__stash}{all_tag_count} = undef; … … 1974 1971 defined(my $out = $builder->build($ctx, $tokens, $cond)) 1975 1972 or return $ctx->error( $builder->errstr ); 1976 $res .= $glue if $res ne '';1973 $res .= $glue if defined $glue && length($res) && length($out); 1977 1974 $res .= $out; 1978 1975 } … … 2097 2094 my $entry = $ctx->stash('entry'); 2098 2095 return '' unless $entry; 2099 my $glue = $args->{glue} || '';2096 my $glue = $args->{glue}; 2100 2097 2101 2098 local $ctx->{__stash}{tag_max_count} = undef; … … 2113 2110 defined(my $out = $builder->build($ctx, $tokens, $cond)) 2114 2111 or return $ctx->error( $builder->errstr ); 2115 $res .= $glue if $res ne '';2112 $res .= $glue if defined $glue && length($res) && length($out); 2116 2113 $res .= $out; 2117 2114 } … … 4229 4226 return $ctx->error( $builder->errstr ) unless defined $out; 4230 4227 $last_day = $this_day; 4231 $res .= $glue if defined $glue && $i ;4228 $res .= $glue if defined $glue && $i && length($res) && length($out); 4232 4229 $res .= $out; 4233 4230 $i++; … … 4739 4736 my $builder = $ctx->stash('builder'); 4740 4737 my $tokens = $ctx->stash('tokens'); 4741 my @res; 4738 my $res; 4739 my $glue = $args->{glue}; 4742 4740 for my $cat (@$cats) { 4743 4741 local $ctx->{__stash}->{category} = $cat; 4744 4742 defined(my $out = $builder->build($ctx, $tokens, $cond)) 4745 4743 or return $ctx->error( $builder->errstr ); 4746 push @res, $out if $out ne '';4747 }4748 my $sep = $args->{glue} || '';4749 join $sep, @res;4744 $res .= $glue if defined $glue && length($res) && length($out); 4745 $res .= $out; 4746 } 4747 $res; 4750 4748 } 4751 4749 … … 6314 6312 my $builder = $ctx->stash('builder'); 6315 6313 my $tokens = $ctx->stash('tokens'); 6316 my $glue = exists $args->{glue} ? $args->{glue} : '';6314 my $glue = $args->{glue}; 6317 6315 ## In order for this handler to double as the handler for 6318 6316 ## <MTArchiveList archive_type="Category">, it needs to support … … 6356 6354 ArchiveListFooter => $last })) 6357 6355 or return $ctx->error( $builder->errstr ); 6358 $res .= $glue if $res ne '';6356 $res .= $glue if defined $glue && length($res) && length($out); 6359 6357 $res .= $out; 6360 6358 $cat = $next_cat; … … 6637 6635 my $builder = $ctx->stash('builder'); 6638 6636 my $tokens = $ctx->stash('tokens'); 6639 my @res; 6637 my $res; 6638 my $glue = $args->{glue}; 6640 6639 for my $cat (@$cats) { 6641 6640 next if $e->category && ($cat->label eq $e->category->label); … … 6643 6642 defined(my $out = $builder->build($ctx, $tokens, $cond)) 6644 6643 or return $ctx->error( $builder->errstr ); 6645 push @res, $out;6646 }6647 my $sep = $args->{glue} || '';6648 join $sep, @res;6644 $res .= $glue if defined $glue && length($res) && length($out); 6645 $res .= $out if length($out); 6646 } 6647 $res; 6649 6648 } 6650 6649 … … 7189 7188 # Get the arguments 7190 7189 my $exclude_current = $args->{'exclude_current'}; 7191 my $glue = $args->{'glue'} || '';7190 my $glue = $args->{'glue'}; 7192 7191 7193 7192 # Get the current category … … 7196 7195 return '' if ($cat eq ''); 7197 7196 7198 my @res;7197 my $res; 7199 7198 7200 7199 # Put together the list of parent categories … … 7211 7210 $out = 'cat-' . $c->id; 7212 7211 } 7213 push @res, $out; 7214 } 7215 7216 # Slap them all together with some glue 7217 return join $glue, @res; 7212 $res .= $glue if defined $glue && length($res) && length($out); 7213 $res .= $out if length($out); 7214 } 7215 $res; 7218 7216 } 7219 7217 … … 7922 7920 my $asset = $ctx->stash('asset'); 7923 7921 return '' unless $asset; 7924 my $glue = $args->{glue} || '';7922 my $glue = $args->{glue}; 7925 7923 7926 7924 local $ctx->{__stash}{tag_max_count} = undef; … … 7943 7941 defined(my $out = $builder->build($ctx, $tokens, $cond)) 7944 7942 or return $ctx->error( $builder->errstr ); 7945 $res .= $glue if $res ne '';7943 $res .= $glue if defined $glue && length($res) && length($out); 7946 7944 $res .= $out; 7947 7945 } … … 8850 8848 8851 8849 my $glue = $args->{glue}; 8852 $glue = q() unless defined $glue;8853 8850 8854 8851 my $output = q(); … … 8868 8865 } 8869 8866 )) or return $ctx->error( $build->errstr ); 8870 $output .= $glue if $i > 1;8867 $output .= $glue if defined $glue && $i > 1 && length($output) && length($out); 8871 8868 $output .= $out; 8872 8869 }
