[Templates-cvs] cvs commit: TT3/lib/Template/Tag Closed.pm
cvs@template-toolkit.org
cvs@template-toolkit.org
Thu, 11 Nov 2004 11:56:02 +0000
cvs 04/11/11 11:56:02
Modified: lib/Template/Tag Closed.pm
Log:
* fixed $match->{ offset } to 0
* added $ignore to regex to strip leading/trailing whitespace
Revision Changes Path
1.4 +11 -8 TT3/lib/Template/Tag/Closed.pm
Index: Closed.pm
===================================================================
RCS file: /template-toolkit/TT3/lib/Template/Tag/Closed.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Closed.pm 2004/11/10 17:54:58 1.3
+++ Closed.pm 2004/11/11 11:56:02 1.4
@@ -16,7 +16,7 @@
# modify it under the same terms as Perl itself.
#
# REVISION
-# $Id: Closed.pm,v 1.3 2004/11/10 17:54:58 abw Exp $
+# $Id: Closed.pm,v 1.4 2004/11/11 11:56:02 abw Exp $
#
#========================================================================
@@ -28,7 +28,7 @@
use vars qw( $VERSION $ERROR $DEBUG $TAG );
use base qw( Template::Tag );
-our $VERSION = sprintf("%d.%02d", q$Revision: 1.3 $ =~ /(\d+)\.(\d+)/);
+our $VERSION = sprintf("%d.%02d", q$Revision: 1.4 $ =~ /(\d+)\.(\d+)/);
our $DEBUG = 0 unless defined $DEBUG;
our $ERROR = '';
our $TAG = {
@@ -45,8 +45,9 @@
sub scan {
my ($self, $textref, $handler, $match) = @_;
+ my $ignore = $self->{ ignore } || '';
- $self->debug("scan_closed()\n") if $DEBUG;
+ $self->debug("scan()\n") if $DEBUG;
# save match info locally to make protect re-entrancy
local $self->{ match } = $match;
@@ -57,17 +58,19 @@
return $self->tag_error('no end token defined for tag')
unless defined $endtag and length $endtag;
$endtag = ref $endtag eq 'Regexp' ? $endtag : quotemeta($endtag);
- qr/ \G (.*?) ($endtag) /sx;
+ qr/ \G $ignore (.*?) $ignore ($endtag) /sx;
};
- $self->debug("scanning for end with $regex\n") if $DEBUG;
+ $self->debug("scanning for end of closed tag: $regex\n") if $DEBUG;
# scan for closing tag and report error if not found
return $self->error("no closing tag to match $match->{ start }")
unless $$textref =~ /$regex/gc;
- # TODO: should we set $match->{ offset } to 0, given that we're
- # passing in a new text ref with different length?
+ # for closed tags, we pass in a reference to the new chunk of text
+ # extracted from between the start and end tokens. we need to reset
+ # $match->{ offset } to conform with this
+ $match->{ offset } = 0;
my ($body, $end) = ($1, $2);
$match->{ text } = \$body;
@@ -124,7 +127,7 @@
=head1 VERSION
-$Revision: 1.3 $
+$Revision: 1.4 $
=head1 COPYRIGHT