[Templates-cvs] cvs commit: TT3/lib/Template Scanner.pm

cvs@template-toolkit.org cvs@template-toolkit.org
Fri, 12 Nov 2004 18:34:17 +0000


cvs         04/11/12 18:34:17

  Modified:    lib/Template Scanner.pm
  Log:
  * allow for matching regex to not match (all tags disabled) and last SCAN_FOR_TAGS
  
  Revision  Changes    Path
  1.4       +10 -4     TT3/lib/Template/Scanner.pm
  
  Index: Scanner.pm
  ===================================================================
  RCS file: /template-toolkit/TT3/lib/Template/Scanner.pm,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Scanner.pm	2004/11/10 17:57:34	1.3
  +++ Scanner.pm	2004/11/12 18:34:17	1.4
  @@ -20,7 +20,7 @@
   #   Handle multiple lines for nested calls.
   #
   # REVISION
  -#   $Id: Scanner.pm,v 1.3 2004/11/10 17:57:34 abw Exp $
  +#   $Id: Scanner.pm,v 1.4 2004/11/12 18:34:17 abw Exp $
   #
   #========================================================================
   
  @@ -32,7 +32,7 @@
   use Template::Tagset;
   use base qw( Template::Base );
   
  -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 $TAGSET  = 'Template::Tagset';
  @@ -91,8 +91,9 @@
   
   sub tags {
       my $self = shift;
  -    my $tagset = $self->{ tagset }
  +    my $tagset = $self->tagset()
           || return $self->decline('no tagset defined in scanner');
  +
       return $tagset->tags(@_)
           || $self->error($tagset->error());
   }
  @@ -156,6 +157,11 @@
               # a chunk of text (possibly of zero length) in $1 and 
               # a token starting a tag in $2.
               my ($pretext, $start) = ($1, $2);
  +
  +            # If the regex is null (e.g. all tags disabled) then $2
  +            # could be undef, in which case we end the loop.
  +            last SCAN_FOR_TAGS 
  +                unless defined $start;
               
               if (defined $pretext && length $pretext) { 
                   $self->debug("text: ", $self->dump_text($pretext), "\n")
  @@ -388,7 +394,7 @@
   
   =head1 VERSION
   
  -$Revision: 1.3 $
  +$Revision: 1.4 $
   
   =head1 COPYRIGHT