[Templates] subtracting one

Chisel Wright chisel at herlpacker.co.uk
Sat Jul 19 19:12:37 BST 2008


On Sat, Jul 19, 2008 at 10:41:46AM -0400, Thomas, Mark - BLS CTR wrote:
>    I get a parse error with [% series.year - 1 %]. According to the thread at
>    [1]http://www.mail-archive.com/templates@template-toolkit.org/msg05821.html,
>    it is because it is being interpreted as a negative 1 instead of an
>    operator.

I can't get "[% series.year - 1 %]" to raise an error:

---- cut here ----
#!/usr/bin/env perl
use strict;
use warnings;
use Template;

my $template    = Template->new();
my $input       = q{[% series.year - 1%]};
my $data        = { series => {year => 10} };
my $output;

$template->process(\$input, $data, \$output)
    || die $template->error();

print qq{$output\n};
---- cut here ----

chisel at zombie:development$ perl minusone.pl
9

chisel at zombie:development$ perl -MTemplate -le 'print Template->VERSION'
2.19


Chisel
-- 
Chisel Wright
e: chisel at herlpacker.co.uk
w: http://www.herlpacker.co.uk/

  My theory is that Lynx is just a way of making chavs more flammable.



More information about the templates mailing list