Fix {{!value}} out when the value is number 0
keel opened this issue · 5 comments
{{!value}}
out '' when the value is number 0 or boolean false, but{{=value}}
is right, so I think this should be fixed.
I have send a PR, and npm tests passed ,but travis failed by its networking issue, please check.
I would preserve the current behaviour for the sake of backward compatibility. {{!x}}
should only be used with strings, if x can potentially be a number, you should use JS expression (e.g. {{!x||''}}
) or simple interpolation {{=x}}
.
It’s essentially a duplicate of #253
This is IMO a bug. We were searching yesterday the half afternoon for the reason of an issue of our product, and found the problem to be {{! 0 }}
resulting in an empty string.
@epoberezkin I think it's fair enough to handle this issue as a bug, as it's not documented and really
not expected. {{! }}
should for 0
, null
, undefined
, and NaN
IMO behave exactly the same as when using {{= }}
, where the according input is stringified.
The documentation even states it like this:
{{= }} for interpolation
{{! }} for interpolation with encoding
I'd go with treating this as bug and fix. @keel's PR behaves differently for undefined
then the other falsy values – IMO not really necessary but fine when documented.
If you are strongly against changing the current behavior as a patch version update (i.e. to 1.0.4), I'd suggest to have a new major version, where the behavior is documented and stated as breaking change.
If you want, I'd be happy to assist with a PR for the documentation.
@sgruetter it is indeed a breaking change. I agree to release as a patch to 2-beta version that is published - if you prepare PR it should be based on beta branch.
Once published on npm, we can create a link to beta readme from main readme for the visibility.
We could also start a conversation on what should be done do release 2.0 as the main version.