-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not let interpret doT numbers as integer, but as string #77
Comments
No, I assure you that that is not what users really want. You know what types your properties contain; doT doesn't. What if I had two numbers and I wanted to add them? Why would that be a less important use case? |
@Pointy because that's definitely not what you expect from something which clearly should output. |
@bwoebi I apologize for not expressing myself more clearly; also, I think I better understand what you're asking for now. However, I'm a little confused. If
will result in a string concatenation operation, and |
@Pointy Hmm, I think I've done something wrong in the original bug report. The failure is definitely present when both operands are numeric. Then they definitely add up, which my quick fix above fixes. |
Right, OK now that I understand, and I agree that I'd be pretty surprised by that (though I confess it's never happened to me, and I've got a lot of templates). I wonder if a simpler change that involved simply making sure that the |
@Pointy Not really. The operands on the right are evaluated first before it's concatenated to the left... |
@bwoebi yes I've been playing with it and I see what you mean; any time that numbers are involved things can get weird. |
… in examples/express. And sporting new logo by @KevinKirchner
Oh yes, I see this can happen if numbers are somewhere in the middle of the template. |
Addressed in version 1.0.3, closing |
{{=it.number1}}{{=it.number2}}
evaluates to
var += (it.number1)+(it.number2);
which results invar += (it.number1 + it.number2);
. It then concatenates the resulting number tovar
, which is bad.Please evaluate it as
var += String(it.number1)+String(it.number2);
— this is what users really want, I think.Quick fix: change the lines 46 - 49 from:
to:
The text was updated successfully, but these errors were encountered: