V
valued customer
The code snippet below produces an error "unexpected token (LAST)".
Changing the ANYCASE property to false (zero) removes the error and
the code behaves as expected.
The question is, is this a bug? According to the TT2 documentation,
the ANYCASE property has a side effect of precluding reserved words as
variable names, does this also preclude using the 'loop.last'
directive? Any TT2 experts out there? Tips? Suggestions? Thanks in
advance.
### INIT library
use strict;
use warnings;
use Template;
### INIT variables
my $tt =
Template->new( { ANYCASE => 1,}) || die "$Template::ERROR\n";
### INIT Source Data
my $data = { list => [ qw(one two three four five) ]};
### PROCESS TEMPLATE
my $strOut;
$tt->process(\*DATA, $data, \$strOut) || die $tt->error(), "\n";
print $strOut;
__DATA__
[%-FOREACH item = list;
"<BEGIN>\n" IF loop.first;%]
[%- item %]
[%"<END>" IF loop.last;
END;%]
Changing the ANYCASE property to false (zero) removes the error and
the code behaves as expected.
The question is, is this a bug? According to the TT2 documentation,
the ANYCASE property has a side effect of precluding reserved words as
variable names, does this also preclude using the 'loop.last'
directive? Any TT2 experts out there? Tips? Suggestions? Thanks in
advance.
### INIT library
use strict;
use warnings;
use Template;
### INIT variables
my $tt =
Template->new( { ANYCASE => 1,}) || die "$Template::ERROR\n";
### INIT Source Data
my $data = { list => [ qw(one two three four five) ]};
### PROCESS TEMPLATE
my $strOut;
$tt->process(\*DATA, $data, \$strOut) || die $tt->error(), "\n";
print $strOut;
__DATA__
[%-FOREACH item = list;
"<BEGIN>\n" IF loop.first;%]
[%- item %]
[%"<END>" IF loop.last;
END;%]