Open tdammers opened 6 years ago
I think it comes down to personal preference. Myself, I'm not a fan of implicit string to number conversions as I believe the time that is lost by hunting down weird unexpected effects is greater than the time saved by not having to type |int
.
There should also be a decision what do do with strings of the form "23e2" and "1e0".
In Jinja2, the following is a type error:
But in Ginger, we currently have a
ToGVal
instance forText
(and other string types) that tries to parse the string into aScientific
, and if that succeeds, exposes it in theasNumber
field, which means that in Ginger, the above template prints"4"
.So the question here is whether it is more important to keep the current convenience of being able to use numeric strings as numbers, or to be more compatible with jinja2.
I am leaning slightly towards keeping the current behavior, because the problem is essentially just being too lenient (accepting templates that Jinja2 rejects), but everything that works fine on Jinja2 will also work fine on Ginger (i.e. we accept templates that Jinja2 accepts).