Numeric modifier parameters

From: Date: Thu, 26 Feb 2004 17:12:26 +0000
Subject: Numeric modifier parameters
Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-2163@lists.php.net to get a copy of this message
I just created a simple modifier "scale_number" which I use thus: {$data|scale_number:4:-10:20:50} The idea was to scale a value between 4 and 20 to one between -10 and 50. In doing so I discover that this fools Smarty (2.6.0) because of the - sign. I suspect it is being seen as a calculation: ($data|scale_number:4:) - (10:20:50) Is this behaviour correct/desirable? I got a bit lost trying to see how it would be fixed - guess I don't know the compiler well enough. It is possible to work around this with {$data|scale_number:4:"-10":20:50} .. but this is not intuitive. Note that "." also fools Smarty in a similar way: {$data|scale_number:4:10.5:20:50} -- Mark Rogers, More Solutions Ltd

« previous php.smarty.dev (#2163) next »