[Templates-cvs] cvs commit: TT3/lib/Template Context.pm
cvs@template-toolkit.org
cvs@template-toolkit.org
Wed, 01 Dec 2004 17:58:49 +0000
cvs 04/12/01 17:58:48
Modified: lib/Template Context.pm
Log:
* changed child() to only parent to $self if $self is an object
Revision Changes Path
1.6 +8 -7 TT3/lib/Template/Context.pm
Index: Context.pm
===================================================================
RCS file: /template-toolkit/TT3/lib/Template/Context.pm,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Context.pm 2004/12/01 10:46:32 1.5
+++ Context.pm 2004/12/01 17:58:48 1.6
@@ -16,7 +16,7 @@
# modify it under the same terms as Perl itself.
#
# REVISION
-# $Id: Context.pm,v 1.5 2004/12/01 10:46:32 abw Exp $
+# $Id: Context.pm,v 1.6 2004/12/01 17:58:48 abw Exp $
#
#========================================================================
@@ -35,7 +35,7 @@
use constant FETCH => 'fetch';
use constant GET => 'get';
-our $VERSION = sprintf("%d.%02d", q$Revision: 1.5 $ =~ /(\d+)\.(\d+)/);
+our $VERSION = sprintf("%d.%02d", q$Revision: 1.6 $ =~ /(\d+)\.(\d+)/);
our $DEBUG = 0 unless defined $DEBUG;
our $ERROR = '';
our $THROW = 'context';
@@ -104,7 +104,7 @@
my ($name, $context, $items, @many_items, $next);
my $depth = 1;
- $self->debug(" - locating...\n") if $debug;
+ $self->debug(" - locating... \n") if $debug;
local $self->{ THROW } = "context.locate.$resource";
@@ -116,8 +116,6 @@
# Would prevent runaway from loops in parent chain.
CONTEXT: while ($context = shift @contexts) {
- $self->debug( " - context: $context\n" ) if $debug;
-
if ($items = $context->{ $resource }) {
$self->debug(" - located context $resource: $items\n")
if $debug;
@@ -362,7 +360,10 @@
sub child {
my $self = shift;
my $child = $self->new(@_) || return;
- return $child->attach($self);
+
+ # attach child to $self if $self is an object, but don't bother
+ # if it's a class name
+ return ref $self ? $child->attach($self) : $child;
}
@@ -466,7 +467,7 @@
=head1 VERSION
-$Revision: 1.5 $
+$Revision: 1.6 $
=head1 COPYRIGHT