Closed schmoove closed 7 years ago
This is also occurring for {% assign %}, which is really frustrating if you are doing any cumulative totals with Liquid.
Can be fixed by modifying LiquidContext.class.php like so:
public function set($key, $value, $global = false)
{
if ( is_numeric($value) )
{
if ( is_float($value) )
{
$value = (float) $value;
}
else
{
$value = (int) $value;
}
}
if ( $global )
...
Resolved by #30
So if you do:
{{ 1 | plus: 1.5 }}
You will get 2
I would recommend the
(int)
type castings for values returned by the Math Filters be changed to(float)
to avoid this.I'm pretty sure it's not the behaviour of the original Liquid implementation.