[Slim-Checkins] r10900 - in /trunk/server: Bin/ CPAN/ CPAN/Template/
CPAN/Template/Namespace/ CPAN/Template/Plugin/ CPAN/Template/Stash/
CPAN/arch/5.8/MSWin32-x86-multi-thread/auto/Template/Stash/XS/
CPAN/arch/5.8/darwin-thread-multi-2level/auto/Template/Stash/XS/
CPAN/arch/5.8/i386-linux-thread-multi/auto/Template/Stash/XS/
dsully at svn.slimdevices.com
dsully at svn.slimdevices.com
Thu Dec 7 13:51:03 PST 2006
Author: dsully
Date: Thu Dec 7 13:51:02 2006
New Revision: 10900
URL: http://svn.slimdevices.com?rev=10900&view=rev
Log:
Bug: N/A
Description: Update to v2.15 of Template Toolkit, which fixes a memory leak.
Modified:
trunk/server/Bin/build-perl-modules.pl
trunk/server/CPAN/Template.pm
trunk/server/CPAN/Template/Base.pm
trunk/server/CPAN/Template/Config.pm
trunk/server/CPAN/Template/Constants.pm
trunk/server/CPAN/Template/Context.pm
trunk/server/CPAN/Template/Document.pm
trunk/server/CPAN/Template/Exception.pm
trunk/server/CPAN/Template/Filters.pm
trunk/server/CPAN/Template/Grammar.pm
trunk/server/CPAN/Template/Iterator.pm
trunk/server/CPAN/Template/Namespace/Constants.pm
trunk/server/CPAN/Template/Parser.pm
trunk/server/CPAN/Template/Plugin.pm
trunk/server/CPAN/Template/Plugin/Autoformat.pm
trunk/server/CPAN/Template/Plugin/CGI.pm
trunk/server/CPAN/Template/Plugin/Datafile.pm
trunk/server/CPAN/Template/Plugin/Date.pm
trunk/server/CPAN/Template/Plugin/Directory.pm
trunk/server/CPAN/Template/Plugin/Dumper.pm
trunk/server/CPAN/Template/Plugin/File.pm
trunk/server/CPAN/Template/Plugin/Filter.pm
trunk/server/CPAN/Template/Plugin/Format.pm
trunk/server/CPAN/Template/Plugin/HTML.pm
trunk/server/CPAN/Template/Plugin/Image.pm
trunk/server/CPAN/Template/Plugin/Iterator.pm
trunk/server/CPAN/Template/Plugin/Pod.pm
trunk/server/CPAN/Template/Plugin/Procedural.pm
trunk/server/CPAN/Template/Plugin/String.pm
trunk/server/CPAN/Template/Plugin/Table.pm
trunk/server/CPAN/Template/Plugin/URL.pm
trunk/server/CPAN/Template/Plugin/View.pm
trunk/server/CPAN/Template/Plugin/Wrap.pm
trunk/server/CPAN/Template/Plugins.pm
trunk/server/CPAN/Template/Provider.pm
trunk/server/CPAN/Template/Service.pm
trunk/server/CPAN/Template/Stash.pm
trunk/server/CPAN/Template/Stash/Context.pm
trunk/server/CPAN/Template/Stash/XS.pm
trunk/server/CPAN/Template/Test.pm
trunk/server/CPAN/arch/5.8/MSWin32-x86-multi-thread/auto/Template/Stash/XS/XS.dll
trunk/server/CPAN/arch/5.8/darwin-thread-multi-2level/auto/Template/Stash/XS/XS.bundle
trunk/server/CPAN/arch/5.8/i386-linux-thread-multi/auto/Template/Stash/XS/XS.so
Modified: trunk/server/Bin/build-perl-modules.pl
URL: http://svn.slimdevices.com/trunk/server/Bin/build-perl-modules.pl?rev=10900&r1=10899&r2=10900&view=diff
==============================================================================
--- trunk/server/Bin/build-perl-modules.pl (original)
+++ trunk/server/Bin/build-perl-modules.pl Thu Dec 7 13:51:02 2006
@@ -29,7 +29,7 @@
'DBD::mysql' => 'DBD-mysql-3.0002.tar.gz',
'Digest::SHA1' => 'Digest-SHA1-2.11.tar.gz',
'HTML::Parser' => 'HTML-Parser-3.48.tar.gz',
- 'Template' => 'Template-Toolkit-2.14.tar.gz',
+ 'Template' => 'Template-Toolkit-2.15.tar.gz',
'Time::HiRes' => 'Time-HiRes-1.86.tar.gz',
'XML::Parser::Expat' => 'XML-Parser-2.34.tar.gz',
'YAML::Syck' => 'YAML-Syck-0.64.tar.gz',
@@ -37,7 +37,7 @@
# Options for specific packages
my %packageOptions = (
- 'Template-Toolkit-2.14' => {
+ 'Template-Toolkit-2.15' => {
'Makefile.PL' => join(' ', qw(
TT_DOCS=n
Modified: trunk/server/CPAN/Template.pm
URL: http://svn.slimdevices.com/trunk/server/CPAN/Template.pm?rev=10900&r1=10899&r2=10900&view=diff
==============================================================================
--- trunk/server/CPAN/Template.pm (original)
+++ trunk/server/CPAN/Template.pm Thu Dec 7 13:51:02 2006
@@ -17,7 +17,7 @@
# modify it under the same terms as Perl itself.
#
# REVISION
-# $Id: Template.pm,v 2.80 2004/10/04 10:24:10 abw Exp $
+# $Id: Template.pm,v 2.84 2006/02/01 11:55:27 abw Exp $
#
#========================================================================
@@ -38,7 +38,7 @@
## This is the main version number for the Template Toolkit.
## It is extracted by ExtUtils::MakeMaker and inserted in various places.
-$VERSION = '2.14';
+$VERSION = '2.15';
$ERROR = '';
$DEBUG = 0;
$BINMODE = 0 unless defined $BINMODE;
@@ -60,10 +60,10 @@
my ($output, $error);
my $options = (@opts == 1) && UNIVERSAL::isa($opts[0], 'HASH')
? shift(@opts) : { @opts };
+
+ $options->{ binmode } = $BINMODE
+ unless defined $options->{ binmode };
- $options->{ binmode } = $BINMODE
- unless defined $options->{ binmode };
-
# we're using this for testing in t/output.t and t/filter.t so
# don't remove it if you don't want tests to fail...
$self->DEBUG("set binmode\n") if $DEBUG && $options->{ binmode };
@@ -76,7 +76,7 @@
my $outpath = $self->{ OUTPUT_PATH };
$outstream = "$outpath/$outstream" if $outpath;
}
-
+
# send processed template to output stream, checking for error
return ($self->error($error))
if ($error = &_output($outstream, \$output, $options));
@@ -192,7 +192,7 @@
}
elsif (open(FP, ">$where")) {
# binmode option can be 1 or a specific layer, e.g. :utf8
- my $bm = $options->{ binmode };
+ my $bm = $options->{ binmode };
if ($bm && +$bm == 1) {
binmode FP;
}
@@ -937,20 +937,20 @@
=head1 AUTHOR
-Andy Wardley E<lt>abw at andywardley.comE<gt>
-
-L<http://www.andywardley.com/|http://www.andywardley.com/>
+Andy Wardley E<lt>abw at wardley.orgE<gt>
+
+L<http://wardley.org/|http://wardley.org/>
=head1 VERSION
-Template Toolkit version 2.14, released on 04 October 2004.
+Template Toolkit version 2.15, released on 26 May 2006.
=head1 COPYRIGHT
- Copyright (C) 1996-2004 Andy Wardley. All Rights Reserved.
+ Copyright (C) 1996-2006 Andy Wardley. All Rights Reserved.
Copyright (C) 1998-2002 Canon Research Centre Europe Ltd.
This module is free software; you can redistribute it and/or
Modified: trunk/server/CPAN/Template/Base.pm
URL: http://svn.slimdevices.com/trunk/server/CPAN/Template/Base.pm?rev=10900&r1=10899&r2=10900&view=diff
==============================================================================
--- trunk/server/CPAN/Template/Base.pm (original)
+++ trunk/server/CPAN/Template/Base.pm Thu Dec 7 13:51:02 2006
@@ -18,7 +18,7 @@
#
#------------------------------------------------------------------------
#
-# $Id: Base.pm,v 2.70 2004/01/30 19:32:21 abw Exp $
+# $Id: Base.pm,v 2.71 2006/01/30 20:04:49 abw Exp $
#
#========================================================================
@@ -30,7 +30,7 @@
use vars qw( $VERSION );
use Template::Constants;
-$VERSION = sprintf("%d.%02d", q$Revision: 2.70 $ =~ /(\d+)\.(\d+)/);
+$VERSION = sprintf("%d.%02d", q$Revision: 2.71 $ =~ /(\d+)\.(\d+)/);
#------------------------------------------------------------------------
@@ -279,21 +279,21 @@
=head1 AUTHOR
-Andy Wardley E<lt>abw at andywardley.comE<gt>
-
-L<http://www.andywardley.com/|http://www.andywardley.com/>
+Andy Wardley E<lt>abw at wardley.orgE<gt>
+
+L<http://wardley.org/|http://wardley.org/>
=head1 VERSION
-2.70, distributed as part of the
-Template Toolkit version 2.14, released on 04 October 2004.
+2.71, distributed as part of the
+Template Toolkit version 2.15, released on 26 May 2006.
=head1 COPYRIGHT
- Copyright (C) 1996-2004 Andy Wardley. All Rights Reserved.
+ Copyright (C) 1996-2006 Andy Wardley. All Rights Reserved.
Copyright (C) 1998-2002 Canon Research Centre Europe Ltd.
This module is free software; you can redistribute it and/or
Modified: trunk/server/CPAN/Template/Config.pm
URL: http://svn.slimdevices.com/trunk/server/CPAN/Template/Config.pm?rev=10900&r1=10899&r2=10900&view=diff
==============================================================================
--- trunk/server/CPAN/Template/Config.pm (original)
+++ trunk/server/CPAN/Template/Config.pm Thu Dec 7 13:51:02 2006
@@ -6,33 +6,30 @@
# Template Toolkit configuration module.
#
# AUTHOR
-# Andy Wardley <abw at kfs.org>
+# Andy Wardley <abw at cpan.org>
#
# COPYRIGHT
-# Copyright (C) 1996-2000 Andy Wardley. All Rights Reserved.
-# Copyright (C) 1998-2000 Canon Research Centre Europe Ltd.
+# Copyright (C) 1996-2006 Andy Wardley. All Rights Reserved.
#
# This module is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
#
-#------------------------------------------------------------------------
-#
-# $Id: Config.pm,v 2.68 2004/01/30 19:32:23 abw Exp $
+# REVISION
+# $Id: Config.pm,v 2.70 2006/02/01 09:12:40 abw Exp $
#
#========================================================================
package Template::Config;
-require 5.004;
-
use strict;
+use warnings;
use base qw( Template::Base );
use vars qw( $VERSION $DEBUG $ERROR $INSTDIR
- $PARSER $PROVIDER $PLUGINS $FILTERS $ITERATOR
+ $PARSER $PROVIDER $PLUGINS $FILTERS $ITERATOR
$LATEX_PATH $PDFLATEX_PATH $DVIPS_PATH
- $STASH $SERVICE $CONTEXT $CONSTANTS @PRELOAD );
-
-$VERSION = sprintf("%d.%02d", q$Revision: 2.68 $ =~ /(\d+)\.(\d+)/);
+ $STASH $SERVICE $CONTEXT $CONSTANTS @PRELOAD );
+
+$VERSION = sprintf("%d.%02d", q$Revision: 2.70 $ =~ /(\d+)\.(\d+)/);
$DEBUG = 0 unless defined $DEBUG;
$ERROR = '';
$CONTEXT = 'Template::Context';
@@ -86,25 +83,16 @@
# or undef on error. Use $class->error() to examine the error string.
#------------------------------------------------------------------------
-my %loaded = ();
-
sub load {
my ($class, $module) = @_;
$module =~ s[::][/]g;
$module .= '.pm';
-
- return 1 if $loaded{$module};
# print STDERR "loading $module\n"
# if $DEBUG;
eval {
require $module;
};
-
- if ($@) {
- return $class->error("failed to load $module: $@");
- }
-
- return $loaded{$module} = 1;
+ return $@ ? $class->error("failed to load $module: $@") : 1;
}
@@ -143,8 +131,8 @@
return undef unless $class->load($PROVIDER);
return $PROVIDER->new($params)
- || $class->error("failed to create template provider: ",
- $PROVIDER->error);
+ || $class->error("failed to create template provider: ",
+ $PROVIDER->error);
}
@@ -441,21 +429,21 @@
=head1 AUTHOR
-Andy Wardley E<lt>abw at andywardley.comE<gt>
-
-L<http://www.andywardley.com/|http://www.andywardley.com/>
+Andy Wardley E<lt>abw at wardley.orgE<gt>
+
+L<http://wardley.org/|http://wardley.org/>
=head1 VERSION
-2.68, distributed as part of the
-Template Toolkit version 2.14, released on 04 October 2004.
+2.70, distributed as part of the
+Template Toolkit version 2.15, released on 26 May 2006.
=head1 COPYRIGHT
- Copyright (C) 1996-2004 Andy Wardley. All Rights Reserved.
+ Copyright (C) 1996-2006 Andy Wardley. All Rights Reserved.
Copyright (C) 1998-2002 Canon Research Centre Europe Ltd.
This module is free software; you can redistribute it and/or
Modified: trunk/server/CPAN/Template/Constants.pm
URL: http://svn.slimdevices.com/trunk/server/CPAN/Template/Constants.pm?rev=10900&r1=10899&r2=10900&view=diff
==============================================================================
--- trunk/server/CPAN/Template/Constants.pm (original)
+++ trunk/server/CPAN/Template/Constants.pm Thu Dec 7 13:51:02 2006
@@ -9,29 +9,29 @@
# Andy Wardley <abw at kfs.org>
#
# COPYRIGHT
-# Copyright (C) 1996-2000 Andy Wardley. All Rights Reserved.
+# Copyright (C) 1996-2006 Andy Wardley. All Rights Reserved.
# Copyright (C) 1998-2000 Canon Research Centre Europe Ltd.
#
# This module is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
#
-#----------------------------------------------------------------------------
-#
-# $Id: Constants.pm,v 2.68 2004/01/30 19:32:23 abw Exp $
+# REVISION
+# $Id: Constants.pm,v 2.71 2006/05/25 11:23:35 abw Exp $
#
#============================================================================
package Template::Constants;
-require 5.004;
require Exporter;
use strict;
-use vars qw( $VERSION @ISA @EXPORT_OK %EXPORT_TAGS );
+use warnings;
+use base 'Exporter';
+
+use vars qw( @EXPORT_OK %EXPORT_TAGS );
use vars qw( $DEBUG_OPTIONS @STATUS @ERROR @CHOMP @DEBUG);
- at ISA = qw( Exporter );
-$VERSION = sprintf("%d.%02d", q$Revision: 2.68 $ =~ /(\d+)\.(\d+)/);
+our $VERSION = sprintf("%d.%02d", q$Revision: 2.71 $ =~ /(\d+)\.(\d+)/);
#========================================================================
@@ -57,8 +57,10 @@
# CHOMP constants for PRE_CHOMP and POST_CHOMP
use constant CHOMP_NONE => 0; # do not remove whitespace
-use constant CHOMP_ALL => 1; # remove whitespace
+use constant CHOMP_ALL => 1; # remove whitespace up to newline
+use constant CHOMP_ONE => 1; # new name for CHOMP_ALL
use constant CHOMP_COLLAPSE => 2; # collapse whitespace to a single space
+use constant CHOMP_GREEDY => 3; # remove all whitespace including newlines
# DEBUG constants to enable various debugging options
use constant DEBUG_OFF => 0; # do nothing
@@ -100,7 +102,7 @@
STATUS_DECLINED STATUS_ERROR );
@ERROR = qw( ERROR_FILE ERROR_VIEW ERROR_UNDEF ERROR_PERL
ERROR_RETURN ERROR_FILTER ERROR_PLUGIN );
- at CHOMP = qw( CHOMP_NONE CHOMP_ALL CHOMP_COLLAPSE );
+ at CHOMP = qw( CHOMP_NONE CHOMP_ALL CHOMP_ONE CHOMP_COLLAPSE CHOMP_GREEDY );
@DEBUG = qw( DEBUG_OFF DEBUG_ON DEBUG_UNDEF DEBUG_VARS
DEBUG_DIRS DEBUG_STASH DEBUG_CONTEXT DEBUG_PARSER
DEBUG_PROVIDER DEBUG_PLUGINS DEBUG_FILTERS DEBUG_SERVICE
@@ -228,8 +230,10 @@
:chomp # for PRE_CHOMP and POST_CHOMP
CHOMP_NONE # do not remove whitespace
- CHOMP_ALL # remove whitespace
+ CHOMP_ONE # remove whitespace to newline
+ CHOMP_ALL # old name for CHOMP_ONE (deprecated)
CHOMP_COLLAPSE # collapse whitespace to a single space
+ CHOMP_GREEDY # remove all whitespace including newlines
:debug
DEBUG_OFF # do nothing
@@ -252,21 +256,21 @@
=head1 AUTHOR
-Andy Wardley E<lt>abw at andywardley.comE<gt>
-
-L<http://www.andywardley.com/|http://www.andywardley.com/>
+Andy Wardley E<lt>abw at wardley.orgE<gt>
+
+L<http://wardley.org/|http://wardley.org/>
=head1 VERSION
-2.68, distributed as part of the
-Template Toolkit version 2.14, released on 04 October 2004.
+2.71, distributed as part of the
+Template Toolkit version 2.15, released on 26 May 2006.
=head1 COPYRIGHT
- Copyright (C) 1996-2004 Andy Wardley. All Rights Reserved.
+ Copyright (C) 1996-2006 Andy Wardley. All Rights Reserved.
Copyright (C) 1998-2002 Canon Research Centre Europe Ltd.
This module is free software; you can redistribute it and/or
Modified: trunk/server/CPAN/Template/Context.pm
URL: http://svn.slimdevices.com/trunk/server/CPAN/Template/Context.pm?rev=10900&r1=10899&r2=10900&view=diff
==============================================================================
--- trunk/server/CPAN/Template/Context.pm (original)
+++ trunk/server/CPAN/Template/Context.pm Thu Dec 7 13:51:02 2006
@@ -18,7 +18,7 @@
# modify it under the same terms as Perl itself.
#
# REVISION
-# $Id: Context.pm,v 2.91 2004/10/04 10:02:29 abw Exp $
+# $Id: Context.pm,v 2.96 2006/02/01 09:11:59 abw Exp $
#
#============================================================================
@@ -35,7 +35,7 @@
use Template::Constants;
use Template::Exception;
-$VERSION = sprintf("%d.%02d", q$Revision: 2.91 $ =~ /(\d+)\.(\d+)/);
+$VERSION = sprintf("%d.%02d", q$Revision: 2.96 $ =~ /(\d+)\.(\d+)/);
$DEBUG_FORMAT = "\n## \$file line \$line : [% \$text %] ##\n";
@@ -370,7 +370,7 @@
# instead?
pop(@{$element->{ callers }})
- if (UNIVERSAL::isa($element, 'Template::Document'));
+ if (UNIVERSAL::isa($component, 'Template::Document'));
}
$stash->set('component', $component);
};
@@ -426,38 +426,38 @@
FILE: foreach $file (@$files) {
- my $name = $file;
-
- if ($^O eq 'MSWin32') {
- # let C:/foo through
- $prefix = $1 if $name =~ s/^(\w{2,})://o;
- }
- else {
- $prefix = $1 if $name =~ s/^(\w+)://;
- }
-
- if (defined $prefix) {
- $providers = $self->{ PREFIX_MAP }->{ $prefix }
- || return $self->throw(Template::Constants::ERROR_FILE,
- "no providers for file prefix '$prefix'");
- }
- else {
- $providers = $self->{ PREFIX_MAP }->{ default }
- || $self->{ LOAD_TEMPLATES };
- }
-
- foreach my $provider (@$providers) {
- ($text, $error) = $provider->load($name, $prefix);
- next FILE unless $error;
- if ($error == Template::Constants::STATUS_ERROR) {
- $self->throw($text) if ref $text;
- $self->throw(Template::Constants::ERROR_FILE, $text);
- }
- }
- $self->throw(Template::Constants::ERROR_FILE, "$file: not found");
+ my $name = $file;
+
+ if ($^O eq 'MSWin32') {
+ # let C:/foo through
+ $prefix = $1 if $name =~ s/^(\w{2,})://o;
+ }
+ else {
+ $prefix = $1 if $name =~ s/^(\w+)://;
+ }
+
+ if (defined $prefix) {
+ $providers = $self->{ PREFIX_MAP }->{ $prefix }
+ || return $self->throw(Template::Constants::ERROR_FILE,
+ "no providers for file prefix '$prefix'");
+ }
+ else {
+ $providers = $self->{ PREFIX_MAP }->{ default }
+ || $self->{ LOAD_TEMPLATES };
+ }
+
+ foreach my $provider (@$providers) {
+ ($text, $error) = $provider->load($name, $prefix);
+ next FILE unless $error;
+ if ($error == Template::Constants::STATUS_ERROR) {
+ $self->throw($text) if ref $text;
+ $self->throw(Template::Constants::ERROR_FILE, $text);
+ }
+ }
+ $self->throw(Template::Constants::ERROR_FILE, "$file: not found");
}
continue {
- $output .= $text;
+ $output .= $text;
}
return $output;
}
@@ -496,14 +496,14 @@
# die! die! die!
if (UNIVERSAL::isa($error, 'Template::Exception')) {
- die $error;
+ die $error;
}
elsif (defined $info) {
- die (Template::Exception->new($error, $info, $output));
+ die (Template::Exception->new($error, $info, $output));
}
else {
- $error ||= '';
- die (Template::Exception->new('undef', $error, $output));
+ $error ||= '';
+ die (Template::Exception->new('undef', $error, $output));
}
# not reached
@@ -533,11 +533,11 @@
my ($self, $error, $output) = @_;
if (UNIVERSAL::isa($error, 'Template::Exception')) {
- $error->text($output) if $output;
- return $error;
+ $error->text($output) if $output;
+ return $error;
}
else {
- return Template::Exception->new('undef', $error, $output);
+ return Template::Exception->new('undef', $error, $output);
}
}
@@ -588,7 +588,7 @@
#
# The leave() method is called when the document has finished
# processing itself. This removes the entry from the BLKSTACK list
-# that was added visit() above. For persistance of BLOCK definitions,
+# that was added visit() above. For persistence of BLOCK definitions,
# the process() method (i.e. the PROCESS directive) does some extra
# magic to copy BLOCKs into a shared hash.
#------------------------------------------------------------------------
@@ -606,15 +606,15 @@
# be specified as a reference to a sub-routine or Template::Document
# object or as text which is compiled into a template. Returns a true
# value (the $block reference or compiled block reference) if
-# succesful or undef on failure. Call error() to retrieve the
+# successful or undef on failure. Call error() to retrieve the
# relevent error message (i.e. compilation failure).
#------------------------------------------------------------------------
sub define_block {
my ($self, $name, $block) = @_;
$block = $self->template(\$block)
- || return undef
- unless ref $block;
+ || return undef
+ unless ref $block;
$self->{ BLOCKS }->{ $name } = $block;
}
@@ -631,13 +631,13 @@
$filter = [ $filter, 1 ] if $is_dynamic;
foreach my $provider (@{ $self->{ LOAD_FILTERS } }) {
- ($result, $error) = $provider->store($name, $filter);
- return 1 unless $error;
- $self->throw(&Template::Constants::ERROR_FILTER, $result)
- if $error == &Template::Constants::STATUS_ERROR;
+ ($result, $error) = $provider->store($name, $filter);
+ return 1 unless $error;
+ $self->throw(&Template::Constants::ERROR_FILTER, $result)
+ if $error == &Template::Constants::STATUS_ERROR;
}
$self->throw(&Template::Constants::ERROR_FILTER,
- "FILTER providers declined to store filter $name");
+ "FILTER providers declined to store filter $name");
}
@@ -697,28 +697,28 @@
# print "*** debug(@args)\n";
if (@args) {
- if ($args[0] =~ /^on|1$/i) {
- $self->{ DEBUG_DIRS } = 1;
- shift(@args);
- }
- elsif ($args[0] =~ /^off|0$/i) {
- $self->{ DEBUG_DIRS } = 0;
- shift(@args);
- }
+ if ($args[0] =~ /^on|1$/i) {
+ $self->{ DEBUG_DIRS } = 1;
+ shift(@args);
+ }
+ elsif ($args[0] =~ /^off|0$/i) {
+ $self->{ DEBUG_DIRS } = 0;
+ shift(@args);
+ }
}
if (@args) {
- if ($args[0] =~ /^msg$/i) {
+ if ($args[0] =~ /^msg$/i) {
return unless $self->{ DEBUG_DIRS };
- my $format = $self->{ DEBUG_FORMAT };
- $format = $DEBUG_FORMAT unless defined $format;
- $format =~ s/\$(\w+)/$hash->{ $1 }/ge;
- return $format;
- }
- elsif ($args[0] =~ /^format$/i) {
- $self->{ DEBUG_FORMAT } = $args[1];
- }
- # else ignore
+ my $format = $self->{ DEBUG_FORMAT };
+ $format = $DEBUG_FORMAT unless defined $format;
+ $format =~ s/\$(\w+)/$hash->{ $1 }/ge;
+ return $format;
+ }
+ elsif ($args[0] =~ /^format$/i) {
+ $self->{ DEBUG_FORMAT } = $args[1];
+ }
+ # else ignore
}
return '';
@@ -743,7 +743,7 @@
return if $method eq 'DESTROY';
warn "no such context method/member: $method\n"
- unless defined ($result = $self->{ uc $method });
+ unless defined ($result = $self->{ uc $method });
return $result;
}
@@ -777,56 +777,53 @@
my ($self, $config) = @_;
my ($name, $item, $method, $block, $blocks);
my @itemlut = (
- LOAD_TEMPLATES => 'provider',
- LOAD_PLUGINS => 'plugins',
- LOAD_FILTERS => 'filters'
+ LOAD_TEMPLATES => 'provider',
+ LOAD_PLUGINS => 'plugins',
+ LOAD_FILTERS => 'filters'
);
# LOAD_TEMPLATE, LOAD_PLUGINS, LOAD_FILTERS - lists of providers
while (($name, $method) = splice(@itemlut, 0, 2)) {
- $item = $config->{ $name }
- || Template::Config->$method($config)
- || return $self->error($Template::Config::ERROR);
- $self->{ $name } = ref $item eq 'ARRAY' ? $item : [ $item ];
+ $item = $config->{ $name }
+ || Template::Config->$method($config)
+ || return $self->error($Template::Config::ERROR);
+ $self->{ $name } = ref $item eq 'ARRAY' ? $item : [ $item ];
}
my $providers = $self->{ LOAD_TEMPLATES };
my $prefix_map = $self->{ PREFIX_MAP } = $config->{ PREFIX_MAP } || { };
while (my ($key, $val) = each %$prefix_map) {
- $prefix_map->{ $key } = [ ref $val ? $val :
- map { $providers->[$_] }
- split(/\D+/, $val) ]
- unless ref $val eq 'ARRAY';
-# print(STDERR "prefix $key => $val => [",
-# join(', ', @{ $prefix_map->{ $key } }), "]\n");
+ $prefix_map->{ $key } = [ ref $val ? $val :
+ map { $providers->[$_] } split(/\D+/, $val) ]
+ unless ref $val eq 'ARRAY';
}
# STASH
$self->{ STASH } = $config->{ STASH } || do {
- my $predefs = $config->{ VARIABLES }
- || $config->{ PRE_DEFINE }
- || { };
-
- # hack to get stash to know about debug mode
- $predefs->{ _DEBUG } = ( ($config->{ DEBUG } || 0)
- & &Template::Constants::DEBUG_UNDEF ) ? 1 : 0
- unless defined $predefs->{ _DEBUG };
-
- Template::Config->stash($predefs)
- || return $self->error($Template::Config::ERROR);
+ my $predefs = $config->{ VARIABLES }
+ || $config->{ PRE_DEFINE }
+ || { };
+
+ # hack to get stash to know about debug mode
+ $predefs->{ _DEBUG } = ( ($config->{ DEBUG } || 0)
+ & &Template::Constants::DEBUG_UNDEF ) ? 1 : 0
+ unless defined $predefs->{ _DEBUG };
+
+ Template::Config->stash($predefs)
+ || return $self->error($Template::Config::ERROR);
};
-
+
# compile any template BLOCKS specified as text
$blocks = $config->{ BLOCKS } || { };
$self->{ INIT_BLOCKS } = $self->{ BLOCKS } = {
- map {
- $block = $blocks->{ $_ };
- $block = $self->template(\$block)
- || return undef
- unless ref $block;
- ($_ => $block);
- }
- keys %$blocks
+ map {
+ $block = $blocks->{ $_ };
+ $block = $self->template(\$block)
+ || return undef
+ unless ref $block;
+ ($_ => $block);
+ }
+ keys %$blocks
};
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -874,18 +871,18 @@
my $key;
foreach $key (qw( RECURSION EVAL_PERL TRIM )) {
- $output .= sprintf($format, $key, $self->{ $key });
+ $output .= sprintf($format, $key, $self->{ $key });
}
foreach my $pname (qw( LOAD_TEMPLATES LOAD_PLUGINS LOAD_FILTERS )) {
- my $provtext = "[\n";
- foreach my $prov (@{ $self->{ $pname } }) {
- $provtext .= $prov->_dump();
-# $provtext .= ",\n";
- }
- $provtext =~ s/\n/\n /g;
- $provtext =~ s/\s+$//;
- $provtext .= ",\n ]";
- $output .= sprintf($format, $pname, $provtext);
+ my $provtext = "[\n";
+ foreach my $prov (@{ $self->{ $pname } }) {
+ $provtext .= $prov->_dump();
+# $provtext .= ",\n";
+ }
+ $provtext =~ s/\n/\n /g;
+ $provtext =~ s/\s+$//;
+ $provtext .= ",\n ]";
+ $output .= sprintf($format, $pname, $provtext);
}
$output .= sprintf($format, STASH => $self->{ STASH }->_dump());
$output .= '}';
@@ -1545,21 +1542,21 @@
=head1 AUTHOR
-Andy Wardley E<lt>abw at andywardley.comE<gt>
-
-L<http://www.andywardley.com/|http://www.andywardley.com/>
+Andy Wardley E<lt>abw at wardley.orgE<gt>
+
+L<http://wardley.org/|http://wardley.org/>
=head1 VERSION
-2.91, distributed as part of the
-Template Toolkit version 2.14, released on 04 October 2004.
+2.96, distributed as part of the
+Template Toolkit version 2.15, released on 26 May 2006.
=head1 COPYRIGHT
- Copyright (C) 1996-2004 Andy Wardley. All Rights Reserved.
+ Copyright (C) 1996-2006 Andy Wardley. All Rights Reserved.
Copyright (C) 1998-2002 Canon Research Centre Europe Ltd.
This module is free software; you can redistribute it and/or
Modified: trunk/server/CPAN/Template/Document.pm
URL: http://svn.slimdevices.com/trunk/server/CPAN/Template/Document.pm?rev=10900&r1=10899&r2=10900&view=diff
==============================================================================
--- trunk/server/CPAN/Template/Document.pm (original)
+++ trunk/server/CPAN/Template/Document.pm Thu Dec 7 13:51:02 2006
@@ -20,7 +20,7 @@
#
#----------------------------------------------------------------------------
#
-# $Id: Document.pm,v 2.74 2004/09/17 07:58:36 abw Exp $
+# $Id: Document.pm,v 2.76 2006/01/30 20:04:49 abw Exp $
#
#============================================================================
@@ -33,16 +33,16 @@
use base qw( Template::Base );
use Template::Constants;
-$VERSION = sprintf("%d.%02d", q$Revision: 2.74 $ =~ /(\d+)\.(\d+)/);
+$VERSION = sprintf("%d.%02d", q$Revision: 2.76 $ =~ /(\d+)\.(\d+)/);
BEGIN {
# UNICODE is supported in versions of Perl from 5.008 onwards
if ($UNICODE = $] > 5.007 ? 1 : 0) {
- if ($^V gt v5.8.0) {
+ if ($] > 5.008) {
# utf8::is_utf8() available from Perl 5.8.1 onwards
*is_utf8 = \&utf8::is_utf8;
}
- elsif ($^V eq v5.8.0) {
+ elsif ($] == 5.008) {
# use Encode::is_utf8() for Perl 5.8.0
require Encode;
*is_utf8 = \&Encode::is_utf8;
@@ -466,7 +466,7 @@
=head2 write_perl_file(\%config)
-This package subroutine is provided to effect persistance of compiled
+This package subroutine is provided to effect persistence of compiled
templates. If the COMPILE_EXT option (to indicate a file extension
for saving compiled templates) then the Template::Parser module calls
this subroutine before calling the new() constructor. At this stage,
@@ -474,25 +474,25 @@
containing Perl code. We can write that to a file, enclosed in a
small wrapper which will allow us to susequently require() the file
and have Perl parse and compile it into a Template::Document. Thus we
-have persistance of compiled templates.
+have persistence of compiled templates.
=head1 AUTHOR
-Andy Wardley E<lt>abw at andywardley.comE<gt>
-
-L<http://www.andywardley.com/|http://www.andywardley.com/>
+Andy Wardley E<lt>abw at wardley.orgE<gt>
+
+L<http://wardley.org/|http://wardley.org/>
=head1 VERSION
-2.74, distributed as part of the
-Template Toolkit version 2.14, released on 04 October 2004.
+2.76, distributed as part of the
+Template Toolkit version 2.15, released on 26 May 2006.
=head1 COPYRIGHT
- Copyright (C) 1996-2004 Andy Wardley. All Rights Reserved.
+ Copyright (C) 1996-2006 Andy Wardley. All Rights Reserved.
Copyright (C) 1998-2002 Canon Research Centre Europe Ltd.
This module is free software; you can redistribute it and/or
Modified: trunk/server/CPAN/Template/Exception.pm
URL: http://svn.slimdevices.com/trunk/server/CPAN/Template/Exception.pm?rev=10900&r1=10899&r2=10900&view=diff
==============================================================================
--- trunk/server/CPAN/Template/Exception.pm (original)
+++ trunk/server/CPAN/Template/Exception.pm Thu Dec 7 13:51:02 2006
@@ -18,7 +18,7 @@
#
#------------------------------------------------------------------------
#
-# $Id: Exception.pm,v 2.65 2004/01/30 19:32:25 abw Exp $
+# $Id: Exception.pm,v 2.66 2006/01/30 20:04:49 abw Exp $
#
#========================================================================
@@ -36,7 +36,7 @@
use overload q|""| => "as_string", fallback => 1;
-$VERSION = sprintf("%d.%02d", q$Revision: 2.65 $ =~ /(\d+)\.(\d+)/);
+$VERSION = sprintf("%d.%02d", q$Revision: 2.66 $ =~ /(\d+)\.(\d+)/);
#------------------------------------------------------------------------
@@ -219,21 +219,21 @@
=head1 AUTHOR
-Andy Wardley E<lt>abw at andywardley.comE<gt>
-
-L<http://www.andywardley.com/|http://www.andywardley.com/>
+Andy Wardley E<lt>abw at wardley.orgE<gt>
+
+L<http://wardley.org/|http://wardley.org/>
=head1 VERSION
-2.65, distributed as part of the
-Template Toolkit version 2.14, released on 04 October 2004.
+2.66, distributed as part of the
+Template Toolkit version 2.15, released on 26 May 2006.
=head1 COPYRIGHT
- Copyright (C) 1996-2004 Andy Wardley. All Rights Reserved.
+ Copyright (C) 1996-2006 Andy Wardley. All Rights Reserved.
Copyright (C) 1998-2002 Canon Research Centre Europe Ltd.
This module is free software; you can redistribute it and/or
Modified: trunk/server/CPAN/Template/Filters.pm
URL: http://svn.slimdevices.com/trunk/server/CPAN/Template/Filters.pm?rev=10900&r1=10899&r2=10900&view=diff
==============================================================================
--- trunk/server/CPAN/Template/Filters.pm (original)
+++ trunk/server/CPAN/Template/Filters.pm Thu Dec 7 13:51:02 2006
@@ -18,7 +18,7 @@
#
#----------------------------------------------------------------------------
#
-# $Id: Filters.pm,v 2.78 2004/01/30 19:32:25 abw Exp $
+# $Id: Filters.pm,v 2.81 2006/01/30 20:04:54 abw Exp $
#
#============================================================================
@@ -27,11 +27,13 @@
require 5.004;
use strict;
+use warnings;
+use locale;
use base qw( Template::Base );
use vars qw( $VERSION $DEBUG $FILTERS $URI_ESCAPES $PLUGIN_FILTER );
use Template::Constants;
-$VERSION = sprintf("%d.%02d", q$Revision: 2.78 $ =~ /(\d+)\.(\d+)/);
+$VERSION = sprintf("%d.%02d", q$Revision: 2.81 $ =~ /(\d+)\.(\d+)/);
#------------------------------------------------------------------------
@@ -481,15 +483,17 @@
#------------------------------------------------------------------------
sub truncate_filter_factory {
- my ($context, $len) = @_;
+ my ($context, $len, $char) = @_;
$len = 32 unless defined $len;
+ $char = "..." unless defined $char;
return sub {
my $text = shift;
- return $text if length $text < $len;
- return substr($text, 0, $len - 3) . "...";
- }
-}
+ return $text if length $text <= $len;
+ return substr($text, 0, $len - length($char)) . $char;
+ }
+}
+
#------------------------------------------------------------------------
@@ -1047,9 +1051,9 @@
=head2 html
-Converts the characters 'E<lt>', 'E<gt>' and '&' to '<', '>' and
-'&', respectively, protecting them from being interpreted as
-representing HTML tags or entities.
+Converts the characters 'E<lt>', 'E<gt>', '&' and '"' to '<',
+'>', '&', and '"' respectively, protecting them from being
+interpreted as representing HTML tags or entities.
[% FILTER html %]
Binary "<=>" returns -1, 0, or 1 depending on...
@@ -1167,11 +1171,11 @@
ME> blah blah blah
ME> cabbages, rhubard, onions
-=head2 truncate(length)
-
-Truncates the text block to the length specified, or a default length of
-32. Truncated text will be terminated with '...' (i.e. the '...' falls
-inside the required length, rather than appending to it).
+=head2 truncate(length,dots)
+
+Truncates the text block to the length specified, or a default length
+of 32. Truncated text will be terminated with '...' (i.e. the '...'
+falls inside the required length, rather than appending to it).
[% FILTER truncate(21) %]
I have much to say on this matter that has previously
@@ -1181,6 +1185,18 @@
output:
I have much to say...
+
+If you want to use something other than '...' you can pass that as a
+second argument.
+
+ [% FILTER truncate(26, '…') %]
+ I have much to say on this matter that has previously
+ been said on more than one occasion.
+ [% END %]
+
+output:
+
+ I have much to say…
=head2 repeat(iterations)
@@ -1351,83 +1367,27 @@
=head2 latex(outputType)
-Passes the text block to LaTeX and produces either PDF, DVI or
-PostScript output. The 'outputType' argument determines the output
-format and it should be set to one of the strings: "pdf" (default),
-"dvi", or "ps".
-
-The text block should be a complete LaTeX source file.
-
- [% FILTER latex("pdf") -%]
- \documentclass{article}
-
- \begin{document}
-
- \title{A Sample TT2 \LaTeX\ Source File}
- \author{Craig Barratt}
- \maketitle
-
- \section{Introduction}
- This is some text.
-
- \end{document}
- [% END -%]
-
-The output will be a PDF file. You should be careful not to prepend or
-append any extraneous characters or text outside the FILTER block,
-since this text will wrap the (binary) output of the latex filter.
-Notice the END directive uses '-%]' for the END_TAG to remove the
-trailing new line.
-
-One example where you might prepend text is in a CGI script where
-you might include the Content-Type before the latex output, eg:
-
- Content-Type: application/pdf
-
- [% FILTER latex("pdf") -%]
- \documentclass{article}
- \begin{document}
- ...
- \end{document}
- [% END -%]
-
-In other cases you might use the redirect filter to put the output
-into a file, rather than delivering it to stdout. This might be
-suitable for batch scripts:
-
- [% output = FILTER latex("pdf") -%]
- \documentclass{article}
- \begin{document}
- ...
- \end{document}
- [% END; output | redirect("document.pdf", 1) -%]
-
-(Notice the second argument to redirect to force binary mode.)
-
-Note that the latex filter runs one or two external programs, so it
-isn't very fast. But for modest documents the performance is adequate,
-even for interactive applications.
-
-A error of type 'latex' will be thrown if there is an error reported
-by latex, pdflatex or dvips.
+The latex() filter is no longer part of the core Template Toolkit
+distribution as of version 2.15. You can download it as a
+separate Template-Latex distribution from CPAN.
=head1 AUTHOR
-Andy Wardley E<lt>abw at andywardley.comE<gt>
-
-L<http://www.andywardley.com/|http://www.andywardley.com/>
+Andy Wardley E<lt>abw at wardley.orgE<gt>
+
+L<http://wardley.org/|http://wardley.org/>
=head1 VERSION
-2.78, distributed as part of the
-Template Toolkit version 2.14, released on 04 October 2004.
+2.81, distributed as part of the
+Template Toolkit version 2.15, released on 26 May 2006.
=head1 COPYRIGHT
- Copyright (C) 1996-2004 Andy Wardley. All Rights Reserved.
+ Copyright (C) 1996-2006 Andy Wardley. All Rights Reserved.
Copyright (C) 1998-2002 Canon Research Centre Europe Ltd.
This module is free software; you can redistribute it and/or
Modified: trunk/server/CPAN/Template/Grammar.pm
URL: http://svn.slimdevices.com/trunk/server/CPAN/Template/Grammar.pm?rev=10900&r1=10899&r2=10900&view=diff
==============================================================================
--- trunk/server/CPAN/Template/Grammar.pm (original)
+++ trunk/server/CPAN/Template/Grammar.pm Thu Dec 7 13:51:02 2006
@@ -26,7 +26,7 @@
#
#------------------------------------------------------------------------
#
-# $Id: Grammar.pm,v 2.22 2004/01/13 16:19:10 abw Exp $
+# $Id: Grammar.pm,v 2.24 2005/11/29 07:34:53 abw Exp $
#
#========================================================================
@@ -37,7 +37,7 @@
use strict;
use vars qw( $VERSION );
-$VERSION = sprintf("%d.%02d", q$Revision: 2.22 $ =~ /(\d+)\.(\d+)/);
+$VERSION = sprintf("%d.%02d", q$Revision: 2.24 $ =~ /(\d+)\.(\d+)/);
my (@RESERVED, %CMPOP, $LEXTABLE, $RULES, $STATES);
my ($factory, $rawstart);
Modified: trunk/server/CPAN/Template/Iterator.pm
URL: http://svn.slimdevices.com/trunk/server/CPAN/Template/Iterator.pm?rev=10900&r1=10899&r2=10900&view=diff
==============================================================================
--- trunk/server/CPAN/Template/Iterator.pm (original)
+++ trunk/server/CPAN/Template/Iterator.pm Thu Dec 7 13:51:02 2006
@@ -40,7 +40,7 @@
#
#----------------------------------------------------------------------------
#
-# $Id: Iterator.pm,v 2.65 2004/01/30 19:32:26 abw Exp $
+# $Id: Iterator.pm,v 2.66 2006/01/30 20:04:54 abw Exp $
#
#============================================================================
@@ -54,7 +54,7 @@
use Template::Constants;
use Template::Exception;
-$VERSION = sprintf("%d.%02d", q$Revision: 2.65 $ =~ /(\d+)\.(\d+)/);
+$VERSION = sprintf("%d.%02d", q$Revision: 2.66 $ =~ /(\d+)\.(\d+)/);
$DEBUG = 0 unless defined $DEBUG;
@@ -421,21 +421,21 @@
=head1 AUTHOR
-Andy Wardley E<lt>abw at andywardley.comE<gt>
-
-L<http://www.andywardley.com/|http://www.andywardley.com/>
+Andy Wardley E<lt>abw at wardley.orgE<gt>
+
+L<http://wardley.org/|http://wardley.org/>
=head1 VERSION
-2.65, distributed as part of the
-Template Toolkit version 2.14, released on 04 October 2004.
+2.66, distributed as part of the
+Template Toolkit version 2.15, released on 26 May 2006.
=head1 COPYRIGHT
- Copyright (C) 1996-2004 Andy Wardley. All Rights Reserved.
+ Copyright (C) 1996-2006 Andy Wardley. All Rights Reserved.
Copyright (C) 1998-2002 Canon Research Centre Europe Ltd.
This module is free software; you can redistribute it and/or
Modified: trunk/server/CPAN/Template/Namespace/Constants.pm
URL: http://svn.slimdevices.com/trunk/server/CPAN/Template/Namespace/Constants.pm?rev=10900&r1=10899&r2=10900&view=diff
==============================================================================
--- trunk/server/CPAN/Template/Namespace/Constants.pm (original)
+++ trunk/server/CPAN/Template/Namespace/Constants.pm Thu Dec 7 13:51:02 2006
@@ -17,7 +17,7 @@
# modify it under the same terms as Perl itself.
#
# REVISION
-# $Id: Constants.pm,v 1.23 2004/01/30 19:33:09 abw Exp $
+# $Id: Constants.pm,v 1.24 2006/01/30 20:05:39 abw Exp $
#
#============================================================================
@@ -32,7 +32,7 @@
use base qw( Template::Base );
use vars qw( $VERSION $DEBUG );
-$VERSION = sprintf("%d.%02d", q$Revision: 1.23 $ =~ /(\d+)\.(\d+)/);
+$VERSION = sprintf("%d.%02d", q$Revision: 1.24 $ =~ /(\d+)\.(\d+)/);
$DEBUG = 0 unless defined $DEBUG;
@@ -170,21 +170,21 @@
=head1 AUTHOR
-Andy Wardley E<lt>abw at andywardley.comE<gt>
-
-L<http://www.andywardley.com/|http://www.andywardley.com/>
+Andy Wardley E<lt>abw at wardley.orgE<gt>
+
+L<http://wardley.org/|http://wardley.org/>
=head1 VERSION
-1.23, distributed as part of the
-Template Toolkit version 2.14, released on 04 October 2004.
+1.24, distributed as part of the
+Template Toolkit version 2.15, released on 26 May 2006.
=head1 COPYRIGHT
- Copyright (C) 1996-2004 Andy Wardley. All Rights Reserved.
+ Copyright (C) 1996-2006 Andy Wardley. All Rights Reserved.
Copyright (C) 1998-2002 Canon Research Centre Europe Ltd.
This module is free software; you can redistribute it and/or
Modified: trunk/server/CPAN/Template/Parser.pm
URL: http://svn.slimdevices.com/trunk/server/CPAN/Template/Parser.pm?rev=10900&r1=10899&r2=10900&view=diff
==============================================================================
--- trunk/server/CPAN/Template/Parser.pm (original)
+++ trunk/server/CPAN/Template/Parser.pm Thu Dec 7 13:51:02 2006
@@ -9,10 +9,10 @@
# on Francois Desarmenien's Parse::Yapp module. Kudos to him.
#
# AUTHOR
-# Andy Wardley <abw at kfs.org>
+# Andy Wardley <abw at cpan.org>
#
# COPYRIGHT
-# Copyright (C) 1996-2000 Andy Wardley. All Rights Reserved.
+# Copyright (C) 1996-2006 Andy Wardley. All Rights Reserved.
# Copyright (C) 1998-2000 Canon Research Centre Europe Ltd.
#
# This module is free software; you can redistribute it and/or
@@ -29,20 +29,16 @@
# the GNU General Public License or the Artistic License, as
# specified in the Perl README file.
#
-#----------------------------------------------------------------------------
-#
-# $Id: Parser.pm,v 2.82 2004/01/30 19:32:27 abw Exp $
+# REVISION
+# $Id: Parser.pm,v 2.86 2006/05/25 11:43:39 abw Exp $
#
#============================================================================
package Template::Parser;
-require 5.004;
-
use strict;
-use vars qw( $VERSION $DEBUG $ERROR );
-use base qw( Template::Base );
-use vars qw( $TAG_STYLE $DEFAULT_STYLE $QUOTED_ESCAPES );
+use warnings;
+use base 'Template::Base';
use Template::Constants qw( :status :chomp );
use Template::Directive;
@@ -54,16 +50,16 @@
use constant ERROR => 2;
use constant ABORT => 3;
-$VERSION = sprintf("%d.%02d", q$Revision: 2.82 $ =~ /(\d+)\.(\d+)/);
-$DEBUG = 0 unless defined $DEBUG;
-$ERROR = '';
+our $VERSION = sprintf("%d.%02d", q$Revision: 2.86 $ =~ /(\d+)\.(\d+)/);
+our $DEBUG = 0 unless defined $DEBUG;
+our $ERROR = '';
#========================================================================
# -- COMMON TAG STYLES --
#========================================================================
-$TAG_STYLE = {
+our $TAG_STYLE = {
'default' => [ '\[%', '%\]' ],
'template1' => [ '[\[%]%', '%[\]%]' ],
'metatext' => [ '%%', '%%' ],
@@ -76,7 +72,7 @@
$TAG_STYLE->{ template } = $TAG_STYLE->{ tt2 } = $TAG_STYLE->{ default };
-$DEFAULT_STYLE = {
+our $DEFAULT_STYLE = {
START_TAG => $TAG_STYLE->{ default }->[0],
END_TAG => $TAG_STYLE->{ default }->[1],
# TAG_STYLE => 'default',
@@ -88,11 +84,15 @@
EVAL_PERL => 0,
};
-$QUOTED_ESCAPES = {
+our $QUOTED_ESCAPES = {
n => "\n",
r => "\r",
t => "\t",
};
+
+# note that '-' must come first so Perl doesn't think it denotes a range
+our $CHOMP_FLAGS = qr/[-=~+]/;
+
#========================================================================
@@ -305,44 +305,53 @@
$pre = '' unless defined $pre;
$dir = '' unless defined $dir;
- $postlines = 0; # denotes lines chomped
- $prelines = ($pre =~ tr/\n//); # NULL - count only
- $dirlines = ($dir =~ tr/\n//); # ditto
+ $prelines = ($pre =~ tr/\n//); # newlines in preceeding text
+ $dirlines = ($dir =~ tr/\n//); # newlines in directive tag
+ $postlines = 0; # newlines chomped after tag
- # the directive CHOMP options may modify the preceding text
for ($dir) {
- # remove leading whitespace and check for a '-' chomp flag
- s/^([-+\#])?\s*//s;
- if ($1 && $1 eq '#') {
- # comment out entire directive except for any chomp flag
- $dir = ($dir =~ /([-+])$/) ? $1 : '';
+ if (/^\#/) {
+ # comment out entire directive except for any end chomp flag
+ $dir = ($dir =~ /($CHOMP_FLAGS)$/o) ? $1 : '';
}
else {
- $chomp = ($1 && $1 eq '+') ? 0 : ($1 || $prechomp);
-# my $space = $prechomp == &Template::Constants::CHOMP_COLLAPSE
- my $space = $prechomp == CHOMP_COLLAPSE
- ? ' ' : '';
-
- # chomp off whitespace and newline preceding directive
- $chomp and $pre =~ s/(\n|^)([ \t]*)\Z/($1||$2) ? $space : ''/me
- and $1 eq "\n"
- and $prelines++;
+ s/^($CHOMP_FLAGS)?\s*//so;
+ # PRE_CHOMP: process whitespace before tag
+ $chomp = $1 ? $1 : $prechomp;
+ $chomp =~ tr/-=~+/1230/;
+ if ($chomp && $pre) {
+ # chomp off whitespace and newline preceding directive
+ if ($chomp == CHOMP_ALL) {
+ $pre =~ s{ (\n|^) [^\S\n]* \z }{}mx;
+ }
+ elsif ($chomp == CHOMP_COLLAPSE) {
+ $pre =~ s{ (\s+) \z }{ }x;
+ }
+ elsif ($chomp == CHOMP_GREEDY) {
+ $pre =~ s{ (\s+) \z }{}x;
+ }
+ }
}
- # remove trailing whitespace and check for a '-' chomp flag
- s/\s*([-+])?\s*$//s;
- $chomp = ($1 && $1 eq '+') ? 0 : ($1 || $postchomp);
- my $space = $postchomp == &Template::Constants::CHOMP_COLLAPSE
- ? ' ' : '';
-
- $postlines++
- if $chomp and $text =~ s/
- ^
- ([ \t]*)\n # whitespace to newline
- (?:(.|\n)|$) # any char (not EOF)
- /
- (($1||$2) ? $space : '') . (defined $2 ? $2 : '')
- /ex;
+ # POST_CHOMP: process whitespace after tag
+ s/\s*($CHOMP_FLAGS)?\s*$//so;
+ $chomp = $1 ? $1 : $postchomp;
+ $chomp =~ tr/-=~+/1230/;
+ if ($chomp) {
+ if ($chomp == CHOMP_ALL) {
+ $text =~ s{ ^ ([^\S\n]* \n) }{}x
+ && $postlines++;
+ }
+ elsif ($chomp == CHOMP_COLLAPSE) {
+ $text =~ s{ ^ (\s+) }{ }x
+ && ($postlines += $1=~y/\n//);
+ }
+ # any trailing whitespace
+ elsif ($chomp == CHOMP_GREEDY) {
+ $text =~ s{ ^ (\s+) }{}x
+ && ($postlines += $1=~y/\n//);
+ }
+ }
}
# any text preceding the directive can now be added
@@ -350,8 +359,8 @@
push(@tokens, $interp
? [ $pre, $line, 'ITEXT' ]
: ('TEXT', $pre) );
- $line += $prelines;
}
+ $line += $prelines;
# and now the directive, along with line number information
if (length $dir) {
@@ -1040,9 +1049,9 @@
The PRE_CHOMP and POST_CHOMP options can help to clean up some of this
extraneous whitespace. Both are disabled by default.
- my $parser = Template::Parser->new({
- PRE_CHOMP => 1,
- POST_CHOMP => 1,
+ my $parser = Template::Parser-E<gt>new({
+ PRE_CHOMP =E<gt> 1,
+ POST_CHOMP =E<gt> 1,
});
With PRE_CHOMP set to 1, the newline and whitespace preceding a directive
@@ -1050,60 +1059,97 @@
concatenating a line that starts with a directive onto the end of the
previous line.
- Foo <----------.
- |
+ Foo E<lt>----------.
+ |
,---(PRE_CHOMP)----'
|
`-- [% a = 10 %] --.
- |
+ |
,---(POST_CHOMP)---'
|
- `-> Bar
+ `-E<gt> Bar
With POST_CHOMP set to 1, any whitespace after a directive up to and
including the newline will be deleted. This has the effect of joining
a line that ends with a directive onto the start of the next line.
-If PRE_CHOMP or POST_CHOMP is set to 2, then instead of removing all
-the whitespace, the whitespace will be collapsed to a single space.
+If PRE_CHOMP or POST_CHOMP is set to 2, all whitespace including any
+number of newline will be removed and replaced with a single space.
This is useful for HTML, where (usually) a contiguous block of
whitespace is rendered the same as a single space.
-You may use the CHOMP_NONE, CHOMP_ALL, and CHOMP_COLLAPSE constants
-from the Template::Constants module to deactivate chomping, remove
-all whitespace, or collapse whitespace to a single space.
+With PRE_CHOMP or POST_CHOMP set to 3, all adjacent whitespace
+(including newlines) will be removed entirely.
+
+These values are defined as CHOMP_NONE, CHOMP_ONE, CHOMP_COLLAPSE and
+CHOMP_GREEDY constants in the Template::Constants module. CHOMP_ALL
+is also defined as an alias for CHOMP_ONE to provide backwards
+compatability with earlier version of the Template Toolkit.
+
+Additionally the chomp tag modifiers listed below may also be used for
+the PRE_CHOMP and POST_CHOMP configuration.
+
+ my $template = Template-E<gt>new({
+ PRE_CHOMP =E<lt> '~',
+ POST_CHOMP =E<gt> '-',
+ });
PRE_CHOMP and POST_CHOMP can be activated for individual directives by
placing a '-' immediately at the start and/or end of the directive.
- [% FOREACH user = userlist %]
+ [% FOREACH user IN userlist %]
[%- user -%]
[% END %]
-The '-' characters activate both PRE_CHOMP and POST_CHOMP for the one
-directive '[%- name -%]'. Thus, the template will be processed as if
-written:
-
- [% FOREACH user = userlist %][% user %][% END %]
-
-Note that this is the same as if PRE_CHOMP and POST_CHOMP were set
-to CHOMP_ALL; the only way to get the CHOMP_COLLAPSE behavior is
-to set PRE_CHOMP or POST_CHOMP accordingly. If PRE_CHOMP or POST_CHOMP
-is already set to CHOMP_COLLAPSE, using '-' will give you CHOMP_COLLAPSE
-behavior, not CHOMP_ALL behavior.
-
-Similarly, '+' characters can be used to disable PRE_CHOMP or
-POST_CHOMP (i.e. leave the whitespace/newline intact) options on a
-per-directive basis.
+This has the same effect as CHOMP_ONE in removing all whitespace
+before or after the directive up to and including the newline. The
+template will be processed as if written:
+
+ [% FOREACH user IN userlist %][% user %][% END %]
+
+To remove all whitespace including any number of newlines, use the '~'
+character instead.
+
+ [% FOREACH user IN userlist %]
+
+ [%~ user ~%]
+
+ [% END %]
+
+To collapse all whitespace to a single space, use the '=' character.
+
+ [% FOREACH user IN userlist %]
+
+ [%= user =%]
+
+ [% END %]
+
+Here the template is processed as if written:
+
+ [% FOREACH user IN userlist %] [% user %] [% END %]
+
+If you have PRE_CHOMP or POST_CHOMP set as configuration options then
+you can use '+' to disable any chomping options (i.e. leave the
+whitespace intact) on a per-directive basis.
[% FOREACH user = userlist %]
User: [% user +%]
[% END %]
-With POST_CHOMP enabled, the above example would be parsed as if written:
+With POST_CHOMP set to CHOMP_ONE, the above example would be parsed as
+if written:
[% FOREACH user = userlist %]User: [% user %]
[% END %]
+
+For reference, the PRE_CHOMP and POST_CHOMP configuration options may be set to any of the following:
+
+ Constant Value Tag Modifier
+ ----------------------------------
+ CHOMP_NONE 0 +
+ CHOMP_ONE 1 -
+ CHOMP_COLLAPSE 2 =
+ CHOMP_GREEDY 3 ~
@@ -1391,20 +1437,27 @@
=head2 parse($text)
The parse() method parses the text passed in the first parameter and
-returns a reference to a Template::Document object which contains the
-compiled representation of the template text. On error, undef is
+returns a reference to a hash array of data defining the compiled
+representation of the template text, suitable for passing to the
+Template::Document new() constructor method. On error, undef is
returned.
Example:
- $doc = $parser->parse($text)
- || die $parser->error();
+ $data = $parser->parse($text)
+ || die $parser->error();
+
+The $data hash reference returned contains a BLOCK item containing the
+compiled Perl code for the template, a DEFBLOCKS item containing a
+reference to a hash array of sub-template BLOCKs defined within in the
+template, and a METADATA item containing a reference to a hash array
+of metadata values defined in META tags.
=head1 AUTHOR
-Andy Wardley E<lt>abw at andywardley.comE<gt>
-
-L<http://www.andywardley.com/|http://www.andywardley.com/>
+Andy Wardley E<lt>abw at wardley.orgE<gt>
+
+L<http://wardley.org/|http://wardley.org/>
@@ -1413,14 +1466,14 @@
=head1 VERSION
-2.82, distributed as part of the
-Template Toolkit version 2.14, released on 04 October 2004.
+2.86, distributed as part of the
+Template Toolkit version 2.15, released on 26 May 2006.
=head1 COPYRIGHT
- Copyright (C) 1996-2004 Andy Wardley. All Rights Reserved.
+ Copyright (C) 1996-2006 Andy Wardley. All Rights Reserved.
Copyright (C) 1998-2002 Canon Research Centre Europe Ltd.
This module is free software; you can redistribute it and/or
Modified: trunk/server/CPAN/Template/Plugin.pm
URL: http://svn.slimdevices.com/trunk/server/CPAN/Template/Plugin.pm?rev=10900&r1=10899&r2=10900&view=diff
==============================================================================
--- trunk/server/CPAN/Template/Plugin.pm (original)
+++ trunk/server/CPAN/Template/Plugin.pm Thu Dec 7 13:51:02 2006
@@ -19,7 +19,7 @@
#
#----------------------------------------------------------------------------
#
-# $Id: Plugin.pm,v 2.66 2004/01/30 19:32:27 abw Exp $
+# $Id: Plugin.pm,v 2.67 2006/01/30 20:04:54 abw Exp $
#
#============================================================================
@@ -33,7 +33,7 @@
use vars qw( $VERSION $DEBUG $ERROR $AUTOLOAD );
use base qw( Template::Base );
-$VERSION = sprintf("%d.%02d", q$Revision: 2.66 $ =~ /(\d+)\.(\d+)/);
+$VERSION = sprintf("%d.%02d", q$Revision: 2.67 $ =~ /(\d+)\.(\d+)/);
$DEBUG = 0;
@@ -374,21 +374,21 @@
=head1 AUTHOR
-Andy Wardley E<lt>abw at andywardley.comE<gt>
-
-L<http://www.andywardley.com/|http://www.andywardley.com/>
+Andy Wardley E<lt>abw at wardley.orgE<gt>
+
+L<http://wardley.org/|http://wardley.org/>
=head1 VERSION
-2.66, distributed as part of the
-Template Toolkit version 2.14, released on 04 October 2004.
+2.67, distributed as part of the
+Template Toolkit version 2.15, released on 26 May 2006.
=head1 COPYRIGHT
- Copyright (C) 1996-2004 Andy Wardley. All Rights Reserved.
+ Copyright (C) 1996-2006 Andy Wardley. All Rights Reserved.
Copyright (C) 1998-2002 Canon Research Centre Europe Ltd.
This module is free software; you can redistribute it and/or
Modified: trunk/server/CPAN/Template/Plugin/Autoformat.pm
URL: http://svn.slimdevices.com/trunk/server/CPAN/Template/Plugin/Autoformat.pm?rev=10900&r1=10899&r2=10900&view=diff
==============================================================================
--- trunk/server/CPAN/Template/Plugin/Autoformat.pm (original)
+++ trunk/server/CPAN/Template/Plugin/Autoformat.pm Thu Dec 7 13:51:02 2006
@@ -21,7 +21,7 @@
#
#----------------------------------------------------------------------------
#
-# $Id: Autoformat.pm,v 2.65 2004/01/30 19:33:10 abw Exp $
+# $Id: Autoformat.pm,v 2.67 2006/01/30 20:05:46 abw Exp $
#
#============================================================================
@@ -35,7 +35,7 @@
use Template::Plugin;
use Text::Autoformat;
-$VERSION = sprintf("%d.%02d", q$Revision: 2.65 $ =~ /(\d+)\.(\d+)/);
+$VERSION = sprintf("%d.%02d", q$Revision: 2.67 $ =~ /(\d+)\.(\d+)/);
sub new {
my ($class, $context, $options) = @_;
@@ -224,8 +224,7 @@
=head1 VERSION
-2.65, distributed as part of the
-Template Toolkit version 2.14, released on 04 October 2004.
+Template Toolkit version 2.15, released on 26 May 2006.
Modified: trunk/server/CPAN/Template/Plugin/CGI.pm
URL: http://svn.slimdevices.com/trunk/server/CPAN/Template/Plugin/CGI.pm?rev=10900&r1=10899&r2=10900&view=diff
==============================================================================
--- trunk/server/CPAN/Template/Plugin/CGI.pm (original)
+++ trunk/server/CPAN/Template/Plugin/CGI.pm Thu Dec 7 13:51:02 2006
@@ -18,7 +18,7 @@
#
#----------------------------------------------------------------------------
#
-# $Id: CGI.pm,v 2.65 2004/01/30 19:33:14 abw Exp $
+# $Id: CGI.pm,v 2.67 2006/01/30 20:05:47 abw Exp $
#
#============================================================================
@@ -32,7 +32,7 @@
use Template::Plugin;
use CGI;
-$VERSION = sprintf("%d.%02d", q$Revision: 2.65 $ =~ /(\d+)\.(\d+)/);
+$VERSION = sprintf("%d.%02d", q$Revision: 2.67 $ =~ /(\d+)\.(\d+)/);
sub new {
my $class = shift;
@@ -133,21 +133,21 @@
=head1 AUTHOR
-Andy Wardley E<lt>abw at andywardley.comE<gt>
+Andy Wardley E<lt>abw at wardley.orgE<gt>
-L<http://www.andywardley.com/|http://www.andywardley.com/>
+L<http://wardley.org/|http://wardley.org/>
=head1 VERSION
-2.65, distributed as part of the
-Template Toolkit version 2.14, released on 04 October 2004.
+2.67, distributed as part of the
+Template Toolkit version 2.15, released on 26 May 2006.
=head1 COPYRIGHT
- Copyright (C) 1996-2004 Andy Wardley. All Rights Reserved.
+ Copyright (C) 1996-2006 Andy Wardley. All Rights Reserved.
Copyright (C) 1998-2002 Canon Research Centre Europe Ltd.
This module is free software; you can redistribute it and/or
Modified: trunk/server/CPAN/Template/Plugin/Datafile.pm
URL: http://svn.slimdevices.com/trunk/server/CPAN/Template/Plugin/Datafile.pm?rev=10900&r1=10899&r2=10900&view=diff
==============================================================================
--- trunk/server/CPAN/Template/Plugin/Datafile.pm (original)
+++ trunk/server/CPAN/Template/Plugin/Datafile.pm Thu Dec 7 13:51:02 2006
@@ -19,7 +19,7 @@
#
#----------------------------------------------------------------------------
#
-# $Id: Datafile.pm,v 2.67 2004/01/30 19:33:14 abw Exp $
+# $Id: Datafile.pm,v 2.69 2006/01/30 20:05:47 abw Exp $
#
#============================================================================
@@ -32,7 +32,7 @@
use base qw( Template::Plugin );
use Template::Plugin;
-$VERSION = sprintf("%d.%02d", q$Revision: 2.67 $ =~ /(\d+)\.(\d+)/);
+$VERSION = sprintf("%d.%02d", q$Revision: 2.69 $ =~ /(\d+)\.(\d+)/);
sub new {
my ($class, $context, $filename, $params) = @_;
@@ -163,21 +163,21 @@
=head1 AUTHOR
-Andy Wardley E<lt>abw at andywardley.comE<gt>
+Andy Wardley E<lt>abw at wardley.orgE<gt>
-L<http://www.andywardley.com/|http://www.andywardley.com/>
+L<http://wardley.org/|http://wardley.org/>
=head1 VERSION
-2.67, distributed as part of the
-Template Toolkit version 2.14, released on 04 October 2004.
+2.69, distributed as part of the
+Template Toolkit version 2.15, released on 26 May 2006.
=head1 COPYRIGHT
- Copyright (C) 1996-2004 Andy Wardley. All Rights Reserved.
+ Copyright (C) 1996-2006 Andy Wardley. All Rights Reserved.
Copyright (C) 1998-2002 Canon Research Centre Europe Ltd.
This module is free software; you can redistribute it and/or
Modified: trunk/server/CPAN/Template/Plugin/Date.pm
URL: http://svn.slimdevices.com/trunk/server/CPAN/Template/Plugin/Date.pm?rev=10900&r1=10899&r2=10900&view=diff
==============================================================================
--- trunk/server/CPAN/Template/Plugin/Date.pm (original)
+++ trunk/server/CPAN/Template/Plugin/Date.pm Thu Dec 7 13:51:02 2006
@@ -18,7 +18,7 @@
#
#----------------------------------------------------------------------------
#
-# $Id: Date.pm,v 2.72 2004/01/30 19:33:15 abw Exp $
+# $Id: Date.pm,v 2.74 2006/01/30 20:05:48 abw Exp $
#
#============================================================================
@@ -31,7 +31,7 @@
use POSIX ();
-$VERSION = sprintf("%d.%02d", q$Revision: 2.72 $ =~ /(\d+)\.(\d+)/);
+$VERSION = sprintf("%d.%02d", q$Revision: 2.74 $ =~ /(\d+)\.(\d+)/);
$FORMAT = '%H:%M:%S %d-%b-%Y'; # default strftime() format
@LOCALE_SUFFIX = qw( .ISO8859-1 .ISO_8859-15 .US-ASCII .UTF-8 );
@@ -343,8 +343,8 @@
=head1 VERSION
-2.72, distributed as part of the
-Template Toolkit version 2.14, released on 04 October 2004.
+2.74, distributed as part of the
+Template Toolkit version 2.15, released on 26 May 2006.
Modified: trunk/server/CPAN/Template/Plugin/Directory.pm
URL: http://svn.slimdevices.com/trunk/server/CPAN/Template/Plugin/Directory.pm?rev=10900&r1=10899&r2=10900&view=diff
==============================================================================
--- trunk/server/CPAN/Template/Plugin/Directory.pm (original)
+++ trunk/server/CPAN/Template/Plugin/Directory.pm Thu Dec 7 13:51:02 2006
@@ -14,7 +14,7 @@
# modify it under the same terms as Perl itself.
#
# REVISION
-# $Id: Directory.pm,v 2.65 2004/01/30 19:33:15 abw Exp $
+# $Id: Directory.pm,v 2.67 2006/01/30 20:05:48 abw Exp $
#
#============================================================================
@@ -29,7 +29,7 @@
use vars qw( $VERSION );
use base qw( Template::Plugin::File );
-$VERSION = sprintf("%d.%02d", q$Revision: 2.65 $ =~ /(\d+)\.(\d+)/);
+$VERSION = sprintf("%d.%02d", q$Revision: 2.67 $ =~ /(\d+)\.(\d+)/);
#------------------------------------------------------------------------
@@ -394,8 +394,8 @@
=head1 VERSION
-2.65, distributed as part of the
-Template Toolkit version 2.14, released on 04 October 2004.
+2.67, distributed as part of the
+Template Toolkit version 2.15, released on 26 May 2006.
Modified: trunk/server/CPAN/Template/Plugin/Dumper.pm
URL: http://svn.slimdevices.com/trunk/server/CPAN/Template/Plugin/Dumper.pm?rev=10900&r1=10899&r2=10900&view=diff
==============================================================================
--- trunk/server/CPAN/Template/Plugin/Dumper.pm (original)
+++ trunk/server/CPAN/Template/Plugin/Dumper.pm Thu Dec 7 13:51:02 2006
@@ -18,7 +18,7 @@
#
#------------------------------------------------------------------------------
#
-# $Id: Dumper.pm,v 2.65 2004/01/30 19:33:15 abw Exp $
+# $Id: Dumper.pm,v 2.67 2006/01/30 20:05:48 abw Exp $
#
#==============================================================================
@@ -33,7 +33,7 @@
use vars qw( $VERSION $DEBUG @DUMPER_ARGS $AUTOLOAD );
use base qw( Template::Plugin );
-$VERSION = sprintf("%d.%02d", q$Revision: 2.65 $ =~ /(\d+)\.(\d+)/);
+$VERSION = sprintf("%d.%02d", q$Revision: 2.67 $ =~ /(\d+)\.(\d+)/);
$DEBUG = 0 unless defined $DEBUG;
@DUMPER_ARGS = qw( Indent Pad Varname Purity Useqq Terse Freezer
Toaster Deepcopy Quotekeys Bless Maxdepth );
@@ -161,8 +161,8 @@
=head1 VERSION
-2.65, distributed as part of the
-Template Toolkit version 2.14, released on 04 October 2004.
+2.67, distributed as part of the
+Template Toolkit version 2.15, released on 26 May 2006.
Modified: trunk/server/CPAN/Template/Plugin/File.pm
URL: http://svn.slimdevices.com/trunk/server/CPAN/Template/Plugin/File.pm?rev=10900&r1=10899&r2=10900&view=diff
==============================================================================
--- trunk/server/CPAN/Template/Plugin/File.pm (original)
+++ trunk/server/CPAN/Template/Plugin/File.pm Thu Dec 7 13:51:02 2006
@@ -16,28 +16,23 @@
# modify it under the same terms as Perl itself.
#
# REVISION
-# $Id: File.pm,v 2.65 2004/01/30 19:33:16 abw Exp $
+# $Id: File.pm,v 2.68 2006/01/30 20:05:48 abw Exp $
#
#============================================================================
package Template::Plugin::File;
-require 5.004;
-
use strict;
+use warnings;
use Cwd;
use File::Spec;
use File::Basename;
-use Template::Plugin;
-
-use vars qw( $VERSION );
-use base qw( Template::Plugin );
-use vars qw( @STAT_KEYS );
-
-$VERSION = sprintf("%d.%02d", q$Revision: 2.65 $ =~ /(\d+)\.(\d+)/);
-
- at STAT_KEYS = qw( dev ino mode nlink uid gid rdev size
- atime mtime ctime blksize blocks );
+use base 'Template::Plugin';
+
+our $VERSION = sprintf("%d.%02d", q$Revision: 2.68 $ =~ /(\d+)\.(\d+)/);
+
+our @STAT_KEYS = qw( dev ino mode nlink uid gid rdev size
+ atime mtime ctime blksize blocks );
#------------------------------------------------------------------------
@@ -59,14 +54,14 @@
# path, dir, name, root, home
if (File::Spec->file_name_is_absolute($path)) {
- $root = '';
+ $root = '';
}
elsif (($root = $config->{ root })) {
- # strip any trailing '/' from root
- $root =~ s[/$][];
+ # strip any trailing '/' from root
+ $root =~ s[/$][];
}
else {
- $root = '';
+ $root = '';
}
my ($name, $dir, $ext) = fileparse($path, '\.\w+');
@@ -75,36 +70,40 @@
$dir = '' if $dir eq '.';
$name = $name . $ext;
$ext =~ s/^\.//g;
+
my @fields = File::Spec->splitdir($dir);
shift @fields if @fields && ! length $fields[0];
$home = join('/', ('..') x @fields);
$abs = File::Spec->catfile($root ? $root : (), $path);
my $self = {
- path => $path,
- name => $name,
- root => $root,
+ path => $path,
+ name => $name,
+ root => $root,
home => $home,
- dir => $dir,
- ext => $ext,
- abs => $abs,
+ dir => $dir,
+ ext => $ext,
+ abs => $abs,
user => '',
group => '',
isdir => '',
- stat => defined $config->{ stat } ? $config->{ stat }
- : ! $config->{ nostat },
- map { ($_ => '') } @STAT_KEYS,
+ stat => defined $config->{ stat }
+ ? $config->{ stat }
+ : ! $config->{ nostat },
+ map { ($_ => '') } @STAT_KEYS,
};
if ($self->{ stat }) {
- (@stat = stat( $abs ))
- || return $class->throw("$abs: $!");
- @$self{ @STAT_KEYS } = @stat;
- unless ($config->{ noid }) {
- $self->{ user } = eval { &getpwuid( $self->{ uid }) || $self->{ uid } };
- $self->{ group } = eval { getgrgid( $self->{ gid }) || $self->{ gid } };
- }
- $self->{ isdir } = -d $abs;
+ (@stat = stat( $abs ))
+ || return $class->throw("$abs: $!");
+
+ @$self{ @STAT_KEYS } = @stat;
+
+ unless ($config->{ noid }) {
+ $self->{ user } = eval { getpwuid( $self->{ uid }) || $self->{ uid } };
+ $self->{ group } = eval { getgrgid( $self->{ gid }) || $self->{ gid } };
+ }
+ $self->{ isdir } = -d $abs;
}
bless $self, $class;
@@ -346,49 +345,50 @@
[% USE file('/foo/bar/baz.html') %]
- [% file.path %] # /foo/bar/baz.html
- [% file.dir %] # /foo/bar
- [% file.name %] # baz.html
- [% file.home %] # ../..
- [% file.root %] # ''
- [% file.abspath %] # /foo/bar/baz.html
- [% file.ext %] # html
+ [% file.path %] # /foo/bar/baz.html
+ [% file.dir %] # /foo/bar
+ [% file.name %] # baz.html
+ [% file.home %] # ../..
+ [% file.root %] # ''
+ [% file.abs %] # /foo/bar/baz.html
+ [% file.ext %] # html
[% file.mtime %] # 987654321
[% file.atime %] # 987654321
- [% file.uid %] # 500
- [% file.user %] # abw
+ [% file.uid %] # 500
+ [% file.user %] # abw
[% USE file('foo.html') %]
- [% file.path %] # foo.html
- [% file.dir %] # ''
- [% file.name %] # foo.html
+ [% file.path %] # foo.html
+ [% file.dir %] # ''
+ [% file.name %] # foo.html
[% file.root %] # ''
[% file.home %] # ''
- [% file.abspath %] # foo.html
+ [% file.abs %] # foo.html
[% USE file('foo/bar/baz.html') %]
- [% file.path %] # foo/bar/baz.html
- [% file.dir %] # foo/bar
- [% file.name %] # baz.html
+ [% file.path %] # foo/bar/baz.html
+ [% file.dir %] # foo/bar
+ [% file.name %] # baz.html
[% file.root %] # ''
[% file.home %] # ../..
- [% file.abspath %] # foo/bar/baz.html
+ [% file.abs %] # foo/bar/baz.html
[% USE file('foo/bar/baz.html', root='/tmp') %]
- [% file.path %] # foo/bar/baz.html
- [% file.dir %] # foo/bar
- [% file.name %] # baz.html
+ [% file.path %] # foo/bar/baz.html
+ [% file.dir %] # foo/bar
+ [% file.name %] # baz.html
[% file.root %] # /tmp
[% file.home %] # ../..
- [% file.abspath %] # /tmp/foo/bar/baz.html
+ [% file.abs %] # /tmp/foo/bar/baz.html
# calculate other file paths relative to this file and its root
[% USE file('foo/bar/baz.html', root => '/tmp/tt2') %]
+
[% file.path('baz/qux.html') %] # ../../baz/qux.html
- [% file.dir('wiz/woz.html') %] # ../../wiz/woz.html
+ [% file.dir('wiz/woz.html') %] # ../../wiz/woz.html
=head1 AUTHORS
@@ -400,8 +400,8 @@
=head1 VERSION
-2.65, distributed as part of the
-Template Toolkit version 2.14, released on 04 October 2004.
+2.68, distributed as part of the
+Template Toolkit version 2.15, released on 26 May 2006.
Modified: trunk/server/CPAN/Template/Plugin/Filter.pm
URL: http://svn.slimdevices.com/trunk/server/CPAN/Template/Plugin/Filter.pm?rev=10900&r1=10899&r2=10900&view=diff
==============================================================================
--- trunk/server/CPAN/Template/Plugin/Filter.pm (original)
+++ trunk/server/CPAN/Template/Plugin/Filter.pm Thu Dec 7 13:51:02 2006
@@ -17,7 +17,7 @@
# modify it under the same terms as Perl itself.
#
# REVISION
-# $Id: Filter.pm,v 1.31 2004/01/30 19:33:16 abw Exp $
+# $Id: Filter.pm,v 1.33 2006/01/30 20:05:48 abw Exp $
#
#============================================================================
@@ -31,7 +31,7 @@
use base qw( Template::Plugin );
use vars qw( $VERSION $DYNAMIC );
-$VERSION = sprintf("%d.%02d", q$Revision: 1.31 $ =~ /(\d+)\.(\d+)/);
+$VERSION = sprintf("%d.%02d", q$Revision: 1.33 $ =~ /(\d+)\.(\d+)/);
$DYNAMIC = 0 unless defined $DYNAMIC;
@@ -401,21 +401,21 @@
=head1 AUTHOR
-Andy Wardley E<lt>abw at andywardley.comE<gt>
-
-L<http://www.andywardley.com/|http://www.andywardley.com/>
+Andy Wardley E<lt>abw at wardley.orgE<gt>
+
+L<http://wardley.org/|http://wardley.org/>
=head1 VERSION
-1.31, distributed as part of the
-Template Toolkit version 2.14, released on 04 October 2004.
+1.33, distributed as part of the
+Template Toolkit version 2.15, released on 26 May 2006.
=head1 COPYRIGHT
- Copyright (C) 1996-2004 Andy Wardley. All Rights Reserved.
+ Copyright (C) 1996-2006 Andy Wardley. All Rights Reserved.
Copyright (C) 1998-2002 Canon Research Centre Europe Ltd.
This module is free software; you can redistribute it and/or
Modified: trunk/server/CPAN/Template/Plugin/Format.pm
URL: http://svn.slimdevices.com/trunk/server/CPAN/Template/Plugin/Format.pm?rev=10900&r1=10899&r2=10900&view=diff
==============================================================================
--- trunk/server/CPAN/Template/Plugin/Format.pm (original)
+++ trunk/server/CPAN/Template/Plugin/Format.pm Thu Dec 7 13:51:02 2006
@@ -18,7 +18,7 @@
#
#----------------------------------------------------------------------------
#
-# $Id: Format.pm,v 2.65 2004/01/30 19:33:16 abw Exp $
+# $Id: Format.pm,v 2.67 2006/01/30 20:05:48 abw Exp $
#
#============================================================================
@@ -31,7 +31,7 @@
use base qw( Template::Plugin );
use Template::Plugin;
-$VERSION = sprintf("%d.%02d", q$Revision: 2.65 $ =~ /(\d+)\.(\d+)/);
+$VERSION = sprintf("%d.%02d", q$Revision: 2.67 $ =~ /(\d+)\.(\d+)/);
sub new {
@@ -89,21 +89,21 @@
=head1 AUTHOR
-Andy Wardley E<lt>abw at andywardley.comE<gt>
+Andy Wardley E<lt>abw at wardley.orgE<gt>
-L<http://www.andywardley.com/|http://www.andywardley.com/>
+L<http://wardley.org/|http://wardley.org/>
=head1 VERSION
-2.65, distributed as part of the
-Template Toolkit version 2.14, released on 04 October 2004.
+2.67, distributed as part of the
+Template Toolkit version 2.15, released on 26 May 2006.
=head1 COPYRIGHT
- Copyright (C) 1996-2004 Andy Wardley. All Rights Reserved.
+ Copyright (C) 1996-2006 Andy Wardley. All Rights Reserved.
Copyright (C) 1998-2002 Canon Research Centre Europe Ltd.
This module is free software; you can redistribute it and/or
Modified: trunk/server/CPAN/Template/Plugin/HTML.pm
URL: http://svn.slimdevices.com/trunk/server/CPAN/Template/Plugin/HTML.pm?rev=10900&r1=10899&r2=10900&view=diff
==============================================================================
--- trunk/server/CPAN/Template/Plugin/HTML.pm (original)
+++ trunk/server/CPAN/Template/Plugin/HTML.pm Thu Dec 7 13:51:02 2006
@@ -19,7 +19,7 @@
#
#----------------------------------------------------------------------------
#
-# $Id: HTML.pm,v 2.57 2004/01/30 19:33:17 abw Exp $
+# $Id: HTML.pm,v 2.59 2006/01/30 20:05:48 abw Exp $
#
#============================================================================
@@ -32,7 +32,7 @@
use base qw( Template::Plugin );
use Template::Plugin;
-$VERSION = sprintf("%d.%02d", q$Revision: 2.57 $ =~ /(\d+)\.(\d+)/);
+$VERSION = sprintf("%d.%02d", q$Revision: 2.59 $ =~ /(\d+)\.(\d+)/);
sub new {
my ($class, $context, @args) = @_;
@@ -162,21 +162,21 @@
=head1 AUTHOR
-Andy Wardley E<lt>abw at andywardley.comE<gt>
+Andy Wardley E<lt>abw at wardley.orgE<gt>
-L<http://www.andywardley.com/|http://www.andywardley.com/>
+L<http://wardley.org/|http://wardley.org/>
=head1 VERSION
-2.57, distributed as part of the
-Template Toolkit version 2.14, released on 04 October 2004.
+2.59, distributed as part of the
+Template Toolkit version 2.15, released on 26 May 2006.
=head1 COPYRIGHT
- Copyright (C) 1996-2004 Andy Wardley. All Rights Reserved.
+ Copyright (C) 1996-2006 Andy Wardley. All Rights Reserved.
Copyright (C) 1998-2002 Canon Research Centre Europe Ltd.
This module is free software; you can redistribute it and/or
Modified: trunk/server/CPAN/Template/Plugin/Image.pm
URL: http://svn.slimdevices.com/trunk/server/CPAN/Template/Plugin/Image.pm?rev=10900&r1=10899&r2=10900&view=diff
==============================================================================
--- trunk/server/CPAN/Template/Plugin/Image.pm (original)
+++ trunk/server/CPAN/Template/Plugin/Image.pm Thu Dec 7 13:51:02 2006
@@ -13,7 +13,7 @@
# modify it under the same terms as Perl itself.
#
# REVISION
-# $Id: Image.pm,v 1.14 2004/01/30 19:33:17 abw Exp $
+# $Id: Image.pm,v 1.18 2006/01/30 20:05:48 abw Exp $
#
#============================================================================
@@ -31,7 +31,7 @@
use base qw( Template::Plugin );
use vars qw( $VERSION $AUTOLOAD );
-$VERSION = sprintf("%d.%02d", q$Revision: 1.14 $ =~ /(\d+)\.(\d+)/);
+$VERSION = sprintf("%d.%02d", q$Revision: 1.18 $ =~ /(\d+)\.(\d+)/);
BEGIN {
if (eval { require Image::Info; }) {
@@ -85,16 +85,19 @@
$file = File::Spec->catfile($root, $name);
}
else {
- $file = $name;
+ $file = defined $config->{file} ? $config->{file} : $name;
}
# Make a note of whether we are using Image::Size or
# Image::Info -- at least for the test suite
$type = $INC{"Image/Size.pm"} ? "Image::Size" : "Image::Info";
-
+
+ # set a default (empty) alt attribute for tag()
+ $config->{ alt } = '' unless defined $config->{ alt };
+
# do we want to check to see if file exists?
-
bless {
+ %$config,
name => $name,
file => $file,
root => $root,
@@ -135,6 +138,7 @@
return "width=\"$size->[0]\" height=\"$size->[1]\"";
}
+
#------------------------------------------------------------------------
# modtime()
#
@@ -149,6 +153,7 @@
return $self->{ modtime };
}
+
#------------------------------------------------------------------------
# tag(\%options)
#
@@ -159,11 +164,18 @@
my $self = shift;
my $options = ref $_[0] eq 'HASH' ? shift : { @_ };
- my $tag = "<img src=\"$self->{ name }\" " . $self->attr();
+ my $tag = '<img src="' . $self->name() . '" ' . $self->attr();
+
+ # XHTML spec says that the alt attribute is mandatory, so who
+ # are we to argue?
+
+ $options->{ alt } = $self->{ alt }
+ unless defined $options->{ alt };
if (%$options) {
while (my ($key, $val) = each %$options) {
- $tag .= " $key=\"$val\"";
+ my $escaped = escape( $val );
+ $tag .= qq[ $key="$escaped"];
}
}
@@ -172,6 +184,16 @@
return $tag;
}
+sub escape {
+ my ($text) = @_;
+ for ($text) {
+ s/&/&/g;
+ s/</</g;
+ s/>/>/g;
+ s/"/"/g;
+ }
+ $text;
+}
sub throw {
my ($self, $error) = @_;
@@ -231,10 +253,31 @@
[% USE image(name='baz.gif') %]
[% USE Image name='pong.gif' %]
+A "root" parameter can be used to specify the location of the image file:
+
+ [% USE Image(root='/path/to/root', name='images/home.png') %]
+ # image path: /path/to/root/images/home.png
+ # img src: images/home.png
+
+In cases where the image path and image url do not match up, specify the
+file name directly:
+
+ [% USE Image(file='/path/to/home.png', name='/images/home.png') %]
+
+The "alt" parameter can be used to specify an alternate name for the
+image, for use in constructing an XHTML element (see the tag() method
+below).
+
+ [% USE Image('home.png', alt="Home") %]
+
You can also provide an alternate name for an Image plugin object.
[% USE img1 = image 'foo.gif' %]
[% USE img2 = image 'bar.gif' %]
+
+The 'name' method returns the image file name.
+
+ [% img1.name %] # foo.gif
The 'width' and 'height' methods return the width and height of the
image, respectively. The 'size' method returns a reference to a 2
@@ -245,41 +288,47 @@
height: [% image.height %]
size: [% image.size.join(', ') %]
-The 'attr' method returns the height and width as HTML/XML attributes.
-
- [% USE image 'foo.gif' %]
- [% image.attr %]
-
-Typical output:
-
- width="60" height="20"
-
-The 'tag' method returns a complete XHTML tag referencing the image.
-
- [% USE image 'foo.gif' %]
- [% image.tag %]
-
-Typical output:
-
- <img src="foo.gif" width="60" height="20" />
-
-You can provide any additional attributes that should be added to the
-XHTML tag.
-
-
- [% USE image 'foo.gif' %]
- [% image.tag(border=0, class="logo") %]
-
-Typical output:
-
- <img src="foo.gif" width="60" height="20" border="0" class="logo" />
-
The 'modtime' method returns the ctime of the file in question, suitable
for use with date.format:
[% USE image 'foo.gif' %]
[% USE date %]
[% date.format(image.modtime, "%B, %e %Y") %]
+
+The 'attr' method returns the height and width as HTML/XML attributes.
+
+ [% USE image 'foo.gif' %]
+ [% image.attr %]
+
+Typical output:
+
+ width="60" height="20"
+
+The 'tag' method returns a complete XHTML tag referencing the image.
+
+ [% USE image 'foo.gif' %]
+ [% image.tag %]
+
+Typical output:
+
+ <img src="foo.gif" width="60" height="20" alt="" />
+
+You can provide any additional attributes that should be added to the
+XHTML tag.
+
+ [% USE image 'foo.gif' %]
+ [% image.tag(class="logo" alt="Logo") %]
+
+Typical output:
+
+ <img src="foo.gif" width="60" height="20" alt="Logo" class="logo" />
+
+Note that the 'alt' attribute is mandatory in a strict XHTML 'img'
+element (even if it's empty) so it is always added even if you don't
+explicitly provide a value for it. You can do so as an argument to
+the 'tag' method, as shown in the previous example, or as an argument
+
+ [% USE image('foo.gif', alt='Logo') %]
=head1 CATCHING ERRORS
@@ -390,21 +439,21 @@
=head1 AUTHOR
-Andy Wardley E<lt>abw at andywardley.comE<gt>
-
-L<http://www.andywardley.com/|http://www.andywardley.com/>
+Andy Wardley E<lt>abw at wardley.orgE<gt>
+
+L<http://wardley.org/|http://wardley.org/>
=head1 VERSION
-1.14, distributed as part of the
-Template Toolkit version 2.14, released on 04 October 2004.
+1.18, distributed as part of the
+Template Toolkit version 2.15, released on 26 May 2006.
=head1 COPYRIGHT
- Copyright (C) 1996-2004 Andy Wardley. All Rights Reserved.
+ Copyright (C) 1996-2006 Andy Wardley. All Rights Reserved.
Copyright (C) 1998-2002 Canon Research Centre Europe Ltd.
This module is free software; you can redistribute it and/or
Modified: trunk/server/CPAN/Template/Plugin/Iterator.pm
URL: http://svn.slimdevices.com/trunk/server/CPAN/Template/Plugin/Iterator.pm?rev=10900&r1=10899&r2=10900&view=diff
==============================================================================
--- trunk/server/CPAN/Template/Plugin/Iterator.pm (original)
+++ trunk/server/CPAN/Template/Plugin/Iterator.pm Thu Dec 7 13:51:02 2006
@@ -18,7 +18,7 @@
#
#----------------------------------------------------------------------------
#
-# $Id: Iterator.pm,v 2.63 2004/01/30 19:33:17 abw Exp $
+# $Id: Iterator.pm,v 2.65 2006/01/30 20:05:48 abw Exp $
#
#============================================================================
@@ -32,7 +32,7 @@
use Template::Plugin;
use Template::Iterator;
-$VERSION = sprintf("%d.%02d", q$Revision: 2.63 $ =~ /(\d+)\.(\d+)/);
+$VERSION = sprintf("%d.%02d", q$Revision: 2.65 $ =~ /(\d+)\.(\d+)/);
#------------------------------------------------------------------------
# new($context, \@data, \%args)
@@ -83,21 +83,21 @@
=head1 AUTHOR
-Andy Wardley E<lt>abw at andywardley.comE<gt>
+Andy Wardley E<lt>abw at wardley.orgE<gt>
-L<http://www.andywardley.com/|http://www.andywardley.com/>
+L<http://wardley.org/|http://wardley.org/>
=head1 VERSION
-2.63, distributed as part of the
-Template Toolkit version 2.14, released on 04 October 2004.
+2.65, distributed as part of the
+Template Toolkit version 2.15, released on 26 May 2006.
=head1 COPYRIGHT
- Copyright (C) 1996-2004 Andy Wardley. All Rights Reserved.
+ Copyright (C) 1996-2006 Andy Wardley. All Rights Reserved.
Copyright (C) 1998-2002 Canon Research Centre Europe Ltd.
This module is free software; you can redistribute it and/or
Modified: trunk/server/CPAN/Template/Plugin/Pod.pm
URL: http://svn.slimdevices.com/trunk/server/CPAN/Template/Plugin/Pod.pm?rev=10900&r1=10899&r2=10900&view=diff
==============================================================================
--- trunk/server/CPAN/Template/Plugin/Pod.pm (original)
+++ trunk/server/CPAN/Template/Plugin/Pod.pm Thu Dec 7 13:51:02 2006
@@ -15,7 +15,7 @@
# modify it under the same terms as Perl itself.
#
# REVISION
-# $Id: Pod.pm,v 2.63 2004/01/30 19:33:19 abw Exp $
+# $Id: Pod.pm,v 2.66 2006/01/30 20:05:48 abw Exp $
#
#============================================================================
@@ -28,7 +28,7 @@
use vars qw( $VERSION );
use base qw( Template::Plugin );
-$VERSION = sprintf("%d.%02d", q$Revision: 2.63 $ =~ /(\d+)\.(\d+)/);
+$VERSION = sprintf("%d.%02d", q$Revision: 2.66 $ =~ /(\d+)\.(\d+)/);
use Pod::POM;
@@ -81,21 +81,21 @@
=head1 AUTHOR
-Andy Wardley E<lt>abw at andywardley.comE<gt>
+Andy Wardley E<lt>abw at wardley.orgE<gt>
-L<http://www.andywardley.com/|http://www.andywardley.com/>
+L<http://wardley.org/|http://wardley.org/>
=head1 VERSION
-2.63, distributed as part of the
-Template Toolkit version 2.14, released on 04 October 2004.
+2.66, distributed as part of the
+Template Toolkit version 2.15, released on 26 May 2006.
=head1 COPYRIGHT
- Copyright (C) 1996-2004 Andy Wardley. All Rights Reserved.
+ Copyright (C) 1996-2006 Andy Wardley. All Rights Reserved.
Copyright (C) 1998-2002 Canon Research Centre Europe Ltd.
This module is free software; you can redistribute it and/or
Modified: trunk/server/CPAN/Template/Plugin/Procedural.pm
URL: http://svn.slimdevices.com/trunk/server/CPAN/Template/Plugin/Procedural.pm?rev=10900&r1=10899&r2=10900&view=diff
==============================================================================
--- trunk/server/CPAN/Template/Plugin/Procedural.pm (original)
+++ trunk/server/CPAN/Template/Plugin/Procedural.pm Thu Dec 7 13:51:02 2006
@@ -18,7 +18,7 @@
#
#------------------------------------------------------------------------------
#
-# $Id: Procedural.pm,v 1.12 2004/01/30 19:33:20 abw Exp $
+# $Id: Procedural.pm,v 1.14 2006/01/30 20:05:48 abw Exp $
#
#==============================================================================
@@ -31,7 +31,7 @@
use vars qw( $VERSION $DEBUG $AUTOLOAD );
use base qw( Template::Plugin );
-$VERSION = sprintf("%d.%02d", q$Revision: 1.12 $ =~ /(\d+)\.(\d+)/);
+$VERSION = sprintf("%d.%02d", q$Revision: 1.14 $ =~ /(\d+)\.(\d+)/);
$DEBUG = 0 unless defined $DEBUG;
#------------------------------------------------------------------------
@@ -144,8 +144,8 @@
=head1 VERSION
-1.12, distributed as part of the
-Template Toolkit version 2.14, released on 04 October 2004.
+1.14, distributed as part of the
+Template Toolkit version 2.15, released on 26 May 2006.
=head1 COPYRIGHT
Modified: trunk/server/CPAN/Template/Plugin/String.pm
URL: http://svn.slimdevices.com/trunk/server/CPAN/Template/Plugin/String.pm?rev=10900&r1=10899&r2=10900&view=diff
==============================================================================
--- trunk/server/CPAN/Template/Plugin/String.pm (original)
+++ trunk/server/CPAN/Template/Plugin/String.pm Thu Dec 7 13:51:02 2006
@@ -15,7 +15,7 @@
# modify it under the same terms as Perl itself.
#
# REVISION
-# $Id: String.pm,v 2.34 2004/01/30 19:33:20 abw Exp $
+# $Id: String.pm,v 2.37 2006/01/30 20:05:48 abw Exp $
#
#============================================================================
@@ -32,7 +32,7 @@
use overload q|""| => "text",
fallback => 1;
-$VERSION = sprintf("%d.%02d", q$Revision: 2.34 $ =~ /(\d+)\.(\d+)/);
+$VERSION = sprintf("%d.%02d", q$Revision: 2.37 $ =~ /(\d+)\.(\d+)/);
$ERROR = '';
*centre = \*center;
@@ -313,9 +313,29 @@
return $self unless defined $length;
$suffix ||= '';
return $self if CORE::length $self->{ text } <= $length;
- $self->{ text } = substr($self->{ text }, 0,
+ $self->{ text } = CORE::substr($self->{ text }, 0,
$length - CORE::length($suffix)) . $suffix;
return $self;
+}
+
+
+sub substr {
+ my ($self, $offset, $length, $replacement) = @_;
+ $offset ||= 0;
+
+ if(defined $length) {
+ if (defined $replacement) {
+ my $removed = CORE::substr( $self->{text}, $offset, $length );
+ CORE::substr( $self->{text}, $offset, $length ) = $replacement;
+ return $removed;
+ }
+ else {
+ return CORE::substr( $self->{text}, $offset, $length );
+ }
+ }
+ else {
+ return CORE::substr( $self->{text}, $offset );
+ }
}
@@ -559,6 +579,26 @@
...
[% END %]
+=item substr($offset, $length, $replacement)
+
+Returns a substring starting at $offset, for $length characters.
+
+ [% str = String.new('foo bar baz wiz waz woz') %]
+ [% str.substr(4, 3) %] # bar
+
+If $length is not specified then it returns everything from the $offset
+to the end of the string.
+
+ [% str.substr(12) %] # wiz waz woz
+
+If both $length and $replacement are specified, then the method
+replaces everything from $offset for $length characters with
+$replacement. The substring removed from the string is then
+returned.
+
+ [% str.substr(0, 11, 'FOO') %] # foo bar baz
+ [% str %] # FOO wiz waz woz
+
=back
=head2 Mutation Methods
@@ -761,21 +801,21 @@
=head1 AUTHOR
-Andy Wardley E<lt>abw at andywardley.comE<gt>
-
-L<http://www.andywardley.com/|http://www.andywardley.com/>
+Andy Wardley E<lt>abw at wardley.orgE<gt>
+
+L<http://wardley.org/|http://wardley.org/>
=head1 VERSION
-2.34, distributed as part of the
-Template Toolkit version 2.14, released on 04 October 2004.
+2.37, distributed as part of the
+Template Toolkit version 2.15, released on 26 May 2006.
=head1 COPYRIGHT
- Copyright (C) 1996-2004 Andy Wardley. All Rights Reserved.
+ Copyright (C) 1996-2006 Andy Wardley. All Rights Reserved.
Copyright (C) 1998-2002 Canon Research Centre Europe Ltd.
This module is free software; you can redistribute it and/or
Modified: trunk/server/CPAN/Template/Plugin/Table.pm
URL: http://svn.slimdevices.com/trunk/server/CPAN/Template/Plugin/Table.pm?rev=10900&r1=10899&r2=10900&view=diff
==============================================================================
--- trunk/server/CPAN/Template/Plugin/Table.pm (original)
+++ trunk/server/CPAN/Template/Plugin/Table.pm Thu Dec 7 13:51:02 2006
@@ -8,30 +8,27 @@
# from which row and column permutations can be fetched.
#
# AUTHOR
-# Andy Wardley <abw at kfs.org>
+# Andy Wardley <abw at cpan.org>
#
# COPYRIGHT
-# Copyright (C) 2000 Andy Wardley. All Rights Reserved.
+# Copyright (C) 2000-2006 Andy Wardley. All Rights Reserved.
#
# This module is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
#
-#----------------------------------------------------------------------------
-#
-# $Id: Table.pm,v 2.65 2004/01/30 19:33:20 abw Exp $
+# REVISION
+# $Id: Table.pm,v 2.68 2006/05/25 11:23:36 abw Exp $
#
#============================================================================
package Template::Plugin::Table;
-require 5.004;
-
use strict;
-use vars qw( @ISA $VERSION $AUTOLOAD );
-use base qw( Template::Plugin );
-use Template::Plugin;
-
-$VERSION = sprintf("%d.%02d", q$Revision: 2.65 $ =~ /(\d+)\.(\d+)/);
+use warnings;
+use base 'Template::Plugin';
+
+our $VERSION = sprintf("%d.%02d", q$Revision: 2.68 $ =~ /(\d+)\.(\d+)/);
+our $AUTOLOAD;
#------------------------------------------------------------------------
@@ -53,18 +50,18 @@
# or subclass thereof, we call its get_all() method to extract all
# the data it contains
if (UNIVERSAL::isa($data, 'Template::Iterator')) {
- ($data, $error) = $data->get_all();
- return $class->error("iterator failed to provide data for table: ",
- $error)
- if $error;
+ ($data, $error) = $data->get_all();
+ return $class->error("iterator failed to provide data for table: ",
+ $error)
+ if $error;
}
return $class->error('invalid table data, expecting a list')
- unless ref $data eq 'ARRAY';
+ unless ref $data eq 'ARRAY';
$params ||= { };
return $class->error('invalid table parameters, expecting a hash')
- unless ref $params eq 'HASH';
+ unless ref $params eq 'HASH';
# ensure keys are folded to upper case
@$params{ map { uc } keys %$params } = values %$params;
@@ -74,44 +71,44 @@
# calculate number of columns based on a specified number of rows
if ($rows = $params->{ ROWS }) {
- if ($size < $rows) {
- $rows = $size; # pad?
- $cols = 1;
- $coloff = 0;
- }
- else {
- $coloff = $rows - $overlap;
- $cols = int ($size / $coloff)
- + ($size % $coloff > $overlap ? 1 : 0)
- }
+ if ($size < $rows) {
+ $rows = $size; # pad?
+ $cols = 1;
+ $coloff = 0;
+ }
+ else {
+ $coloff = $rows - $overlap;
+ $cols = int ($size / $coloff)
+ + ($size % $coloff > $overlap ? 1 : 0)
+ }
}
# calculate number of rows based on a specified number of columns
elsif ($cols = $params->{ COLS }) {
- if ($size < $cols) {
- $cols = $size;
- $rows = 1;
- $coloff = 1;
- }
- else {
- $coloff = int ($size / $cols)
- + ($size % $cols > $overlap ? 1 : 0);
- $rows = $coloff + $overlap;
- }
+ if ($size < $cols) {
+ $cols = $size;
+ $rows = 1;
+ $coloff = 1;
+ }
+ else {
+ $coloff = int ($size / $cols)
+ + ($size % $cols > $overlap ? 1 : 0);
+ $rows = $coloff + $overlap;
+ }
}
else {
- $rows = $size;
- $cols = 1;
- $coloff = 0;
+ $rows = $size;
+ $cols = 1;
+ $coloff = 0;
}
bless {
- _DATA => $data,
- _SIZE => $size,
- _NROWS => $rows,
- _NCOLS => $cols,
- _COLOFF => $coloff,
- _OVERLAP => $overlap,
- _PAD => defined $params->{ PAD } ? $params->{ PAD } : 1,
+ _DATA => $data,
+ _SIZE => $size,
+ _NROWS => $rows,
+ _NCOLS => $cols,
+ _COLOFF => $coloff,
+ _OVERLAP => $overlap,
+ _PAD => defined $params->{ PAD } ? $params->{ PAD } : 1,
}, $class;
}
@@ -127,22 +124,22 @@
sub row {
my ($self, $row) = @_;
my ($data, $cols, $offset, $size, $pad)
- = @$self{ qw( _DATA _NCOLS _COLOFF _SIZE _PAD) };
+ = @$self{ qw( _DATA _NCOLS _COLOFF _SIZE _PAD) };
my @set;
# return all rows if row number not specified
return $self->rows()
- unless defined $row;
+ unless defined $row;
return () if $row >= $self->{ _NROWS } || $row < 0;
my $index = $row;
for (my $c = 0; $c < $cols; $c++) {
- push(@set, $index < $size
- ? $data->[$index]
- : ($pad ? undef : ()));
- $index += $offset;
+ push(@set, $index < $size
+ ? $data->[$index]
+ : ($pad ? undef : ()));
+ $index += $offset;
}
return \@set;
}
@@ -164,7 +161,7 @@
# return all cols if row number not specified
return $self->cols()
- unless defined $col;
+ unless defined $col;
return () if $col >= $self->{ _NCOLS } || $col < 0;
@@ -172,12 +169,12 @@
$end = $start + $self->{ _NROWS } - 1;
$end = $start if $end < $start;
if ($end >= $size) {
- $blanks = ($end - $size) + 1;
- $end = $size - 1;
+ $blanks = ($end - $size) + 1;
+ $end = $size - 1;
}
return () if $start >= $size;
return [ @$data[$start..$end],
- $self->{ _PAD } ? ((undef) x $blanks) : () ];
+ $self->{ _PAD } ? ((undef) x $blanks) : () ];
}
@@ -217,11 +214,11 @@
$item =~ s/.*:://;
return if $item eq 'DESTROY';
- if ($item =~ /^data|size|nrows|ncols|overlap|pad$/) {
- return $self->{ $item };
+ if ($item =~ /^(?:data|size|nrows|ncols|overlap|pad)$/) {
+ return $self->{ $item };
}
else {
- return (undef, "no such table method: $item");
+ return (undef, "no such table method: $item");
}
}
@@ -429,21 +426,21 @@
=head1 AUTHOR
-Andy Wardley E<lt>abw at andywardley.comE<gt>
-
-L<http://www.andywardley.com/|http://www.andywardley.com/>
+Andy Wardley E<lt>abw at wardley.orgE<gt>
+
+L<http://wardley.org/|http://wardley.org/>
=head1 VERSION
-2.65, distributed as part of the
-Template Toolkit version 2.14, released on 04 October 2004.
+2.68, distributed as part of the
+Template Toolkit version 2.15, released on 26 May 2006.
=head1 COPYRIGHT
- Copyright (C) 1996-2004 Andy Wardley. All Rights Reserved.
+ Copyright (C) 1996-2006 Andy Wardley. All Rights Reserved.
Copyright (C) 1998-2002 Canon Research Centre Europe Ltd.
This module is free software; you can redistribute it and/or
Modified: trunk/server/CPAN/Template/Plugin/URL.pm
URL: http://svn.slimdevices.com/trunk/server/CPAN/Template/Plugin/URL.pm?rev=10900&r1=10899&r2=10900&view=diff
==============================================================================
--- trunk/server/CPAN/Template/Plugin/URL.pm (original)
+++ trunk/server/CPAN/Template/Plugin/URL.pm Thu Dec 7 13:51:02 2006
@@ -8,30 +8,27 @@
# and adaptable parameters.
#
# AUTHOR
-# Andy Wardley <abw at kfs.org>
+# Andy Wardley <abw at cpan.org>
#
# COPYRIGHT
-# Copyright (C) 2000 Andy Wardley. All Rights Reserved.
+# Copyright (C) 2000-2006 Andy Wardley. All Rights Reserved.
#
# This module is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
#
-#----------------------------------------------------------------------------
-#
-# $Id: URL.pm,v 2.65 2004/01/30 19:33:20 abw Exp $
+# REVISION
+# $Id: URL.pm,v 2.71 2006/01/30 20:05:48 abw Exp $
#
#============================================================================
package Template::Plugin::URL;
-require 5.004;
-
use strict;
-use vars qw( @ISA $VERSION );
-use Template::Plugin;
-
- at ISA = qw( Template::Plugin );
-$VERSION = sprintf("%d.%02d", q$Revision: 2.65 $ =~ /(\d+)\.(\d+)/);
+use warnings;
+use base 'Template::Plugin';
+
+our $VERSION = sprintf("%d.%02d", q$Revision: 2.71 $ =~ /(\d+)\.(\d+)/);
+our $JOINT = '&';
#------------------------------------------------------------------------
@@ -46,20 +43,19 @@
$args ||= { };
return sub {
- my $newbase = shift unless ref $_[0] eq 'HASH';
- my $newargs = shift || { };
- my $combo = { %$args, %$newargs };
- my $urlargs = join('&',
-# map { "$_=" . escape($combo->{ $_ }) }
+ my $newbase = shift unless ref $_[0] eq 'HASH';
+ my $newargs = shift || { };
+ my $combo = { %$args, %$newargs };
+ my $urlargs = join($JOINT,
map { args($_, $combo->{ $_ }) }
- grep { defined $combo->{ $_ } }
+ grep { defined $combo->{ $_ } && length $combo->{ $_ } }
sort keys %$combo);
- my $query = $newbase || $base || '';
- $query .= '?' if length $query && length $urlargs;
- $query .= $urlargs if length $urlargs;
-
- return $query
+ my $query = $newbase || $base || '';
+ $query .= '?' if length $query && length $urlargs;
+ $query .= $urlargs if length $urlargs;
+
+ return $query
}
}
@@ -67,8 +63,9 @@
sub args {
my ($key, $val) = @_;
$key = escape($key);
+
return map {
- "$key=" . escape($_);
+ "$key=" . escape($_);
} ref $val eq 'ARRAY' ? @$val : $val;
}
@@ -151,7 +148,15 @@
/cgi-bin/bar.pl?mode=browse
/cgi-bin/baz.pl?mode=browse&debug=1
-Additional parameters may be also be specified:
+Note that additional parameters are seperated by '&' rather than
+simply '&'. This is the correct behaviour for HTML pages but is,
+unfortunately, incorrect when creating URLs that do not need to be
+encoded safely for HTML. This is likely to be corrected in a future
+version of the plugin (most probably with TT3). In the mean time, you
+can set C<$Template::Plugin::URL::JOINT> to C<&> to get the correct
+behaviour.
+
+Additional parameters may be also be specified to the URL:
[% url(mode='submit', id='wiz') %]
@@ -170,7 +175,6 @@
/cgi-bin/waz.pl?test=1
/cgi-bin/waz.pl?mode=browse&test=1
/cgi-bin/waz.pl?mode=browse&debug=1&test=1
-
The ordering of the parameters is non-deterministic due to fact that
Perl's hashes themselves are unordered. This isn't a problem as the
@@ -185,37 +189,30 @@
/cgi-bin/woz.pl?name=Elrich%20von%20Benjy%20d%27Weiro
-Alternate name may be provided for the plugin at construction time
+An alternate name may be provided for the plugin at construction time
as per regular Template Toolkit syntax.
[% USE mycgi = url('cgi-bin/min.pl') %]
[% mycgi(debug=1) %]
-Note that in the following line, additional parameters are seperated
-by '&', while common usage on the Web is to just use '&'. '&'
-is actually the Right Way to do it. See this URL for more information:
-http://ppewww.ph.gla.ac.uk/~flavell/www/formgetbyurl.html
-
- /cgi-bin/waz.pl?mode=browse&debug=1&test=1
-
=head1 AUTHOR
-Andy Wardley E<lt>abw at andywardley.comE<gt>
-
-L<http://www.andywardley.com/|http://www.andywardley.com/>
+Andy Wardley E<lt>abw at wardley.orgE<gt>
+
+L<http://wardley.org/|http://wardley.org/>
=head1 VERSION
-2.65, distributed as part of the
-Template Toolkit version 2.14, released on 04 October 2004.
+2.71, distributed as part of the
+Template Toolkit version 2.15, released on 26 May 2006.
=head1 COPYRIGHT
- Copyright (C) 1996-2004 Andy Wardley. All Rights Reserved.
+ Copyright (C) 1996-2006 Andy Wardley. All Rights Reserved.
Copyright (C) 1998-2002 Canon Research Centre Europe Ltd.
This module is free software; you can redistribute it and/or
Modified: trunk/server/CPAN/Template/Plugin/View.pm
URL: http://svn.slimdevices.com/trunk/server/CPAN/Template/Plugin/View.pm?rev=10900&r1=10899&r2=10900&view=diff
==============================================================================
--- trunk/server/CPAN/Template/Plugin/View.pm (original)
+++ trunk/server/CPAN/Template/Plugin/View.pm Thu Dec 7 13:51:02 2006
@@ -16,7 +16,7 @@
# modify it under the same terms as Perl itself.
#
# REVISION
-# $Id: View.pm,v 2.64 2004/01/30 19:33:20 abw Exp $
+# $Id: View.pm,v 2.66 2006/01/30 20:05:49 abw Exp $
#
#============================================================================
@@ -29,7 +29,7 @@
use vars qw( $VERSION );
use base qw( Template::Plugin );
-$VERSION = sprintf("%d.%02d", q$Revision: 2.64 $ =~ /(\d+)\.(\d+)/);
+$VERSION = sprintf("%d.%02d", q$Revision: 2.66 $ =~ /(\d+)\.(\d+)/);
use Template::View;
@@ -92,21 +92,21 @@
=head1 AUTHOR
-Andy Wardley E<lt>abw at andywardley.comE<gt>
+Andy Wardley E<lt>abw at wardley.orgE<gt>
-L<http://www.andywardley.com/|http://www.andywardley.com/>
+L<http://wardley.org/|http://wardley.org/>
=head1 VERSION
-2.64, distributed as part of the
-Template Toolkit version 2.14, released on 04 October 2004.
+2.66, distributed as part of the
+Template Toolkit version 2.15, released on 26 May 2006.
=head1 COPYRIGHT
- Copyright (C) 1996-2004 Andy Wardley. All Rights Reserved.
+ Copyright (C) 1996-2006 Andy Wardley. All Rights Reserved.
Copyright (C) 1998-2002 Canon Research Centre Europe Ltd.
This module is free software; you can redistribute it and/or
Modified: trunk/server/CPAN/Template/Plugin/Wrap.pm
URL: http://svn.slimdevices.com/trunk/server/CPAN/Template/Plugin/Wrap.pm?rev=10900&r1=10899&r2=10900&view=diff
==============================================================================
--- trunk/server/CPAN/Template/Plugin/Wrap.pm (original)
+++ trunk/server/CPAN/Template/Plugin/Wrap.pm Thu Dec 7 13:51:02 2006
@@ -16,7 +16,7 @@
#
#----------------------------------------------------------------------------
#
-# $Id: Wrap.pm,v 2.64 2004/01/30 19:33:20 abw Exp $
+# $Id: Wrap.pm,v 2.66 2006/01/30 20:05:49 abw Exp $
#
#============================================================================
@@ -30,7 +30,7 @@
use Template::Plugin;
use Text::Wrap;
-$VERSION = sprintf("%d.%02d", q$Revision: 2.64 $ =~ /(\d+)\.(\d+)/);
+$VERSION = sprintf("%d.%02d", q$Revision: 2.66 $ =~ /(\d+)\.(\d+)/);
sub new {
my ($class, $context, $format) = @_;;
@@ -145,12 +145,12 @@
=head1 VERSION
-2.64, distributed as part of the
-Template Toolkit version 2.14, released on 04 October 2004.
+2.66, distributed as part of the
+Template Toolkit version 2.15, released on 26 May 2006.
=head1 COPYRIGHT
- Copyright (C) 1996-2004 Andy Wardley. All Rights Reserved.
+ Copyright (C) 1996-2006 Andy Wardley. All Rights Reserved.
Copyright (C) 1998-2002 Canon Research Centre Europe Ltd.
This module is free software; you can redistribute it and/or
Modified: trunk/server/CPAN/Template/Plugins.pm
URL: http://svn.slimdevices.com/trunk/server/CPAN/Template/Plugins.pm?rev=10900&r1=10899&r2=10900&view=diff
==============================================================================
--- trunk/server/CPAN/Template/Plugins.pm (original)
+++ trunk/server/CPAN/Template/Plugins.pm Thu Dec 7 13:51:02 2006
@@ -18,22 +18,21 @@
#
#----------------------------------------------------------------------------
#
-# $Id: Plugins.pm,v 2.71 2004/01/30 19:32:28 abw Exp $
+# $Id: Plugins.pm,v 2.74 2006/01/30 20:04:54 abw Exp $
#
#============================================================================
package Template::Plugins;
-require 5.004;
-
use strict;
-use base qw( Template::Base );
-use vars qw( $VERSION $DEBUG $STD_PLUGINS );
+use warnings;
+use base 'Template::Base';
use Template::Constants;
-$VERSION = sprintf("%d.%02d", q$Revision: 2.71 $ =~ /(\d+)\.(\d+)/);
-
-$STD_PLUGINS = {
+our $VERSION = sprintf("%d.%02d", q$Revision: 2.74 $ =~ /(\d+)\.(\d+)/);
+our $DEBUG = 0 unless defined $DEBUG;
+our $PLUGIN_BASE = 'Template::Plugin';
+our $STD_PLUGINS = {
'autoformat' => 'Template::Plugin::Autoformat',
'cgi' => 'Template::Plugin::CGI',
'datafile' => 'Template::Plugin::Datafile',
@@ -121,11 +120,12 @@
}
};
if ($error = $@) {
+# chomp $error;
return $self->{ TOLERANT }
- ? (undef, Template::Constants::STATUS_DECLINED)
- : ($error, Template::Constants::STATUS_ERROR);
- }
-
+ ? (undef, Template::Constants::STATUS_DECLINED)
+ : ($error, Template::Constants::STATUS_ERROR);
+ }
+
return $plugin;
}
@@ -147,10 +147,13 @@
@$params{ qw( PLUGIN_BASE PLUGINS PLUGIN_FACTORY ) };
$plugins ||= { };
- if (ref $pbase ne 'ARRAY') {
- $pbase = $pbase ? [ $pbase ] : [ ];
- }
- push(@$pbase, 'Template::Plugin');
+
+ # update PLUGIN_BASE to an array ref if necessary
+ $pbase = [ ] unless defined $pbase;
+ $pbase = [ $pbase ] unless ref($pbase) eq 'ARRAY';
+
+ # add default plugin base (Template::Plugin) if set
+ push(@$pbase, $PLUGIN_BASE) if $PLUGIN_BASE;
$self->{ PLUGIN_BASE } = $pbase;
$self->{ PLUGINS } = { %$STD_PLUGINS, %$plugins };
@@ -177,7 +180,7 @@
my ($self, $name, $context) = @_;
my ($factory, $module, $base, $pkg, $file, $ok, $error);
- if ($module = $self->{ PLUGINS }->{ $name }) {
+ if ($module = $self->{ PLUGINS }->{ $name } || $self->{ PLUGINS }->{ lc $name }) {
# plugin module name is explicitly stated in PLUGIN_NAME
$pkg = $module;
($file = $module) =~ s|::|/|g;
@@ -208,8 +211,8 @@
if ($ok) {
$self->debug("calling $pkg->load()") if $self->{ DEBUG };
-
- $factory = eval { $pkg->load($context) };
+
+ $factory = eval { $pkg->load($context) };
$error = '';
if ($@ || ! $factory) {
$error = $@ || 'load() returned a false value';
@@ -264,14 +267,14 @@
my $key;
foreach $key (qw( TOLERANT LOAD_PERL )) {
- $output .= sprintf($format, $key, $self->{ $key });
+ $output .= sprintf($format, $key, $self->{ $key });
}
local $" = ', ';
my $fkeys = join(", ", keys %{$self->{ FACTORY }});
my $plugins = $self->{ PLUGINS };
$plugins = join('', map {
- sprintf(" $format", $_, $plugins->{ $_ });
+ sprintf(" $format", $_, $plugins->{ $_ });
} keys %$plugins);
$plugins = "{\n$plugins }";
@@ -387,12 +390,24 @@
redefined by values in the PLUGINS hash.
my $plugins = Template::Plugins->new({
- PLUGINS => {
- cgi => 'MyOrg::Template::Plugin::CGI',
- foo => 'MyOrg::Template::Plugin::Foo',
- bar => 'MyOrg::Template::Plugin::Bar',
- },
- });
+ PLUGINS => {
+ cgi => 'MyOrg::Template::Plugin::CGI',
+ foo => 'MyOrg::Template::Plugin::Foo',
+ bar => 'MyOrg::Template::Plugin::Bar',
+ },
+ });
+
+The recommended convention is to specify these plugin names in lower
+case. The Template Toolkit first looks for an exact case-sensitive
+match and then tries the lower case conversion of the name specified.
+
+ [% USE Foo %] # look for 'Foo' then 'foo'
+
+If you define all your PLUGINS with lower case names then they will be
+located regardless of how the user specifies the name in the USE
+directive. If, on the other hand, you define your PLUGINS with upper
+or mixed case names then the name specified in the USE directive must
+match the case exactly.
The USE directive is used to create plugin objects and does so by
calling the plugin() method on the current Template::Context object.
@@ -402,8 +417,8 @@
(default and general case) or a prototype object against which the
new() method can be called to instantiate individual plugin objects.
-If the plugin name is not defined in the PLUGINS hash then the PLUGIN_BASE
-and/or LOAD_PERL options come into effect.
+If the plugin name is not defined in the PLUGINS hash then the
+PLUGIN_BASE and/or LOAD_PERL options come into effect.
@@ -415,17 +430,15 @@
to attempt to construct a correct Perl module name which can be successfully
loaded.
-The PLUGIN_BASE can be specified as a single value or as a reference
-to an array of multiple values. The default PLUGIN_BASE value,
-'Template::Plugin', is alway