[Templates-cvs] cvs commit: Template2/lib/Template Stash.pm Context.pm
cvs@template-toolkit.org
cvs@template-toolkit.org
Thu, 24 Jul 2003 12:32:43 +0100
cvs 03/07/24 11:32:37
Modified: lib/Template Stash.pm Context.pm
Log:
* merged in darren's branch to add define_vmethod() to stash and context.
Revision Changes Path
2.77 +25 -2 Template2/lib/Template/Stash.pm
Index: Stash.pm
===================================================================
RCS file: /template-toolkit/Template2/lib/Template/Stash.pm,v
retrieving revision 2.76
retrieving revision 2.77
diff -u -r2.76 -r2.77
--- Stash.pm 2003/05/21 10:30:39 2.76
+++ Stash.pm 2003/07/24 11:32:35 2.77
@@ -18,7 +18,7 @@
#
#----------------------------------------------------------------------------
#
-# $Id: Stash.pm,v 2.76 2003/05/21 10:30:39 abw Exp $
+# $Id: Stash.pm,v 2.77 2003/07/24 11:32:35 abw Exp $
#
#============================================================================
@@ -29,7 +29,7 @@
use strict;
use vars qw( $VERSION $DEBUG $ROOT_OPS $SCALAR_OPS $HASH_OPS $LIST_OPS );
-$VERSION = sprintf("%d.%02d", q$Revision: 2.76 $ =~ /(\d+)\.(\d+)/);
+$VERSION = sprintf("%d.%02d", q$Revision: 2.77 $ =~ /(\d+)\.(\d+)/);
#========================================================================
@@ -250,6 +250,29 @@
return '';
}
+#------------------------------------------------------------------------
+# define_vmethod($type, $name, \&sub)
+#
+# Defines a virtual method of type $type (SCALAR, HASH, or LIST), with
+# name $name, that invokes &sub when called. It is expected that &sub
+# be able to handle the type that it will be called upon.
+#------------------------------------------------------------------------
+sub define_vmethod {
+ my ($class, $type, $name, $sub) = @_;
+ my $op;
+
+ if (($type = lc $type) eq 'scalar') {
+ $op = $SCALAR_OPS;
+ }
+ elsif ($type eq 'hash') {
+ $op = $HASH_OPS;
+ }
+ elsif ($type eq 'array') {
+ $op = $LIST_OPS;
+ }
+
+ $op->{ $name } = $sub if $op;
+}
#========================================================================
2.81 +16 -5 Template2/lib/Template/Context.pm
Index: Context.pm
===================================================================
RCS file: /template-toolkit/Template2/lib/Template/Context.pm,v
retrieving revision 2.80
retrieving revision 2.81
diff -u -r2.80 -r2.81
--- Context.pm 2003/04/24 09:14:38 2.80
+++ Context.pm 2003/07/24 11:32:35 2.81
@@ -18,7 +18,7 @@
# modify it under the same terms as Perl itself.
#
# REVISION
-# $Id: Context.pm,v 2.80 2003/04/24 09:14:38 abw Exp $
+# $Id: Context.pm,v 2.81 2003/07/24 11:32:35 abw Exp $
#
#============================================================================
@@ -35,7 +35,7 @@
use Template::Constants;
use Template::Exception;
-$VERSION = sprintf("%d.%02d", q$Revision: 2.80 $ =~ /(\d+)\.(\d+)/);
+$VERSION = sprintf("%d.%02d", q$Revision: 2.81 $ =~ /(\d+)\.(\d+)/);
$DEBUG_FORMAT = "\n## \$file line \$line : [% \$text %] ##\n";
@@ -649,6 +649,17 @@
#------------------------------------------------------------------------
+# define_vmethod($type, $name, \&sub)
+#
+# Passes $type, $name, and &sub on to stash->define_vmethod().
+#------------------------------------------------------------------------
+sub define_vmethod {
+ my $self = shift;
+ $self->stash->define_vmethod(@_);
+}
+
+
+#------------------------------------------------------------------------
# debugging($command, @args, \%params)
#
# Method for controlling the debugging status of the context. The first
@@ -1522,8 +1533,8 @@
=head1 VERSION
-2.79, distributed as part of the
-Template Toolkit version 2.09b, released on 24 April 2003.
+2.80, distributed as part of the
+Template Toolkit version 2.09c, released on 29 April 2003.
=head1 COPYRIGHT
@@ -1535,4 +1546,4 @@
=head1 SEE ALSO
-L<Template|Template>, L<Template::Document|Template::Document>, L<Template::Exception|Template::Exception>, L<Template::Filters|Template::Filters>, L<Template::Plugins|Template::Plugins>, L<Template::Provider|Template::Provider>, L<Template::Service|Template::Service>, L<Template::Stash|Template::Stash>
\ No newline at end of file
+L<Template|Template>, L<Template::Document|Template::Document>, L<Template::Exception|Template::Exception>, L<Template::Filters|Template::Filters>, L<Template::Plugins|Template::Plugins>, L<Template::Provider|Template::Provider>, L<Template::Service|Template::Service>, L<Template::Stash|Template::Stash>