-
Notifications
You must be signed in to change notification settings - Fork 106
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
Inconsistency with add operator #32
Comments
Yes, I concur with this. That means bumping the version to 3.0. |
#93 fixes this another way by treating both as arithmetic expressions: RunJetTest(t, data, nil, "actionNode_AddIntString", `{{ 2+"1" }}`, "3")
RunJetTest(t, data, nil, "actionNode_AddStringInt", `{{ "1"+2 }}`, "3") I'm not sure if that's a good idea though (I'll raise the issue over there too) because isn't the use case of a template engine to allow string concatenation without caring about the individual pieces' type? As an example:
I'd really expect this to print This is also related to #83. |
FYI: the twig/jinja etc use ~ as a concat operator. I don't know if this is reserved here, but It's more readable than the dot as dot can easily be lost in the visual clutter. So if there will be a different concat oeprator, then the examples above should succedd, |
@mvrhov I agree with adding a special operator for specific use case like "2" ~ "2" output: "22", but ~ operator is mostly used for regex and binary operations, so it may be confusing ^^
|
I'll add my examples from above as test cases and then I think I'm coming around to favor this approach. It'll still bump the version to v3 because of the potential breakages. |
Taking in example
The first test the left operand is a number and the right is a string then the right operand is converted to a number and the expression is evaluated as add expression.
The second test the left operand is a string and the right is a number the expression is evaluated as a string concatenation.
I propose a breaking change in the template language, adding a operator for string concatenation and let numeric operators to work only with numbers.
Like php $val.$val2.
@annismckenzie
The text was updated successfully, but these errors were encountered: