diff --git a/lib/Template/Parser.pm b/lib/Template/Parser.pm index 9e094dc4..008360e5 100644 --- a/lib/Template/Parser.pm +++ b/lib/Template/Parser.pm @@ -626,10 +626,14 @@ sub tokenise_directive { \2 # match opening quote | # an unquoted number matches in $4 - (-?\d+(?:\.\d+)?) # numbers + # only treat leading - as unary when not after a + # word char, close-paren, or close-bracket (else + # it is a subtraction operator, e.g. x-2) + ((?:(? one: 2[The Title] [% triple(10) %] -- expect -- 30 + +-- test -- +-- name macro with arithmetic expressions (GH #315) -- +[% MACRO show(n) BLOCK -%] +[% n %] +[%- END -%] +[% x = 5 -%] +[% show(x) %]:[% show(x+2) %]:[% show(x-2) %]:[% show(x*2) %]:[% show(x/2) %] +-- expect -- +5:7:3:10:2.5