osteele / liquid

A Liquid template engine in Go
https://godoc.org/github.com/osteele/liquid
MIT License
287 stars 59 forks source link

Don't panic when applying the `divided_by` filter with zero divisor #96

Closed jamslinger closed 4 weeks ago

jamslinger commented 4 weeks ago

Checklist

Expected Behavior

Don't panic when applying the divided_by filter with zero divisor, instead raise an error.

Actual Behavior

Filter evaluation panics when divided_by is applied with zero divisor:

{{ 20 | divided_by: 0 }} -> panics

Detailed Description

In liquidjs, when dividing by zero, Inf is returned and in Shopify an error is returned.

Possible Solution

When evaluating an expression where divided_by is used with a zero divisor, don't panic, instead return an error.