Coercing Strings to Integers Inside Filters #49
Labels
incompatibility
Behavioural differences between Python and Ruby Liquid
wontfix
This will not be worked on
Many filters built in to Liquid will automatically convert a string representation of a number to an integer or float as needed.
When converting integers, Ruby Liquid uses Ruby's String.to_i method, which will disregard trailing non-digit characters. In the following example,
'7,42'
is converted to7
template:
output
Python Liquid currently falls back to
0
for any string that can't be converted to an integer in its entirety. As is the case in Ruby Liquid for strings without leading digits.This does not apply to parsing of integer literals, only converting strings to integers (not floats) inside filters.
The text was updated successfully, but these errors were encountered: