[Templates-cvs] cvs commit: TT3/lib/Template Utils.pm
cvs@template-toolkit.org
cvs@template-toolkit.org
Wed, 24 Mar 2004 14:17:59 +0000
cvs 04/03/24 14:17:59
Modified: lib/Template Utils.pm
Log:
* added the template_path() method
Revision Changes Path
1.2 +13 -10 TT3/lib/Template/Utils.pm
Index: Utils.pm
===================================================================
RCS file: /template-toolkit/TT3/lib/Template/Utils.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Utils.pm 2004/03/23 11:05:30 1.1
+++ Utils.pm 2004/03/24 14:17:59 1.2
@@ -20,7 +20,7 @@
# modify it under the same terms as Perl itself.
#
# REVISION
-# $Id: Utils.pm,v 1.1 2004/03/23 11:05:30 abw Exp $
+# $Id: Utils.pm,v 1.2 2004/03/24 14:17:59 abw Exp $
#
#========================================================================
@@ -37,7 +37,7 @@
use vars qw( $VERSION $DEBUG $ERROR );
use base qw( Template::Base );
-$VERSION = sprintf("%d.%02d", q$Revision: 1.1 $ =~ /(\d+)\.(\d+)/);
+$VERSION = sprintf("%d.%02d", q$Revision: 1.2 $ =~ /(\d+)\.(\d+)/);
$DEBUG = 0 unless defined $DEBUG;
$ERROR = '';
@@ -125,24 +125,27 @@
}
-
#------------------------------------------------------------------------
-# path($path1, $path2, $path3, ...)
+# template_path($path1, $path2, $path3, ...)
#
# Similar to file_path() but always uses '/' as a path separator rather
# than any OS specific value.
#------------------------------------------------------------------------
-sub path {
- # TODO: this should always use '/' for TT paths, regardless of OS
- my $self = shift;
- File::Spec->catfile(@_);
+sub template_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__
@@ -257,7 +260,7 @@
=head1 VERSION
-$Revision: 1.1 $
+$Revision: 1.2 $
=head1 COPYRIGHT