harrydeluxe / php-liquid

A PHP port of Ruby's Liquid Templates
http://www.delacap.com/artikel/Liquid-Templates/
MIT License
239 stars 119 forks source link

refactor math filters to permit float variables (as ruby lib does) #30

Closed kodekrash closed 7 years ago

kodekrash commented 8 years ago

Test template

plus = {{ 0.5 | plus: 1 }}
minus = {{ 0.5 | minus: 0.25 }}
times = {{ 0.5 | times: 0.25 }}
divided_by = {{ 0.5 | divided_by: 2 }}

Results in both my fork, and ruby liquid

plus = 1.5
minus = 0.25
times = 0.125
divided_by = 0.25
schmoove commented 8 years ago

This addresses the issue I raised here:

https://github.com/harrydeluxe/php-liquid/issues/28

+1 for this PR

schmoove commented 8 years ago

Hey @kodekrash, it looks like there's a similar issue with {% assign %} :

{% assign foo = 1.55 %}
{{ foo }}

Outputs: 1

Very frustrating, but I'm not sure how to best modify LiquidTagAssign.class.php - any suggestions would be much appreciated!

kodekrash commented 8 years ago

@schmoove Using my fork, I can't reproduce that issue. For me, your template renders as 1.55, not 1.