[Templates-cvs] cvs commit: TT3/lib/Template Utils.pm

cvs@template-toolkit.org cvs@template-toolkit.org
Wed, 10 Nov 2004 18:07:38 +0000


cvs         04/11/10 18:07:38

  Modified:    lib/Template Utils.pm
  Log:
  * added module_path()
  
  Revision  Changes    Path
  1.3       +24 -3     TT3/lib/Template/Utils.pm
  
  Index: Utils.pm
  ===================================================================
  RCS file: /template-toolkit/TT3/lib/Template/Utils.pm,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Utils.pm	2004/03/24 14:17:59	1.2
  +++ Utils.pm	2004/11/10 18:07:38	1.3
  @@ -20,7 +20,7 @@
   #   modify it under the same terms as Perl itself.
   #
   # REVISION
  -#   $Id: Utils.pm,v 1.2 2004/03/24 14:17:59 abw Exp $
  +#   $Id: Utils.pm,v 1.3 2004/11/10 18:07:38 abw Exp $
   #
   #========================================================================
   
  @@ -37,7 +37,7 @@
   use vars qw( $VERSION $DEBUG $ERROR );
   use base qw( Template::Base );
   
  -$VERSION = sprintf("%d.%02d", q$Revision: 1.2 $ =~ /(\d+)\.(\d+)/);
  +$VERSION = sprintf("%d.%02d", q$Revision: 1.3 $ =~ /(\d+)\.(\d+)/);
   $DEBUG   = 0 unless defined $DEBUG;
   $ERROR   = '';
   
  @@ -146,6 +146,27 @@
   }
   
   
  +#------------------------------------------------------------------------
  +# module_path($path1, $path2, $path3, ...)
  +#
  +# Similar to file_path() but uses '::' as a path separator to build 
  +# Perl module paths.
  +#------------------------------------------------------------------------
  +
  +sub module_path {
  +    my ($self, @paths) = @_;
  +    my $path = '';
  +    my $next;
  +    while (@paths) {
  +        $next  = shift @paths;
  +        $next  =~ s[^::][];
  +        $path .= '::' unless $path =~ m[::$];
  +        $path .= $next;
  +    }
  +    return $path;
  +}
  +
  +
   1;
   __END__
   
  @@ -260,7 +281,7 @@
   
   =head1 VERSION
   
  -$Revision: 1.2 $
  +$Revision: 1.3 $
   
   =head1 COPYRIGHT