Skip to content
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

Twig ~ operator does not compile correctly #123

Open
cpatti97100 opened this issue Jun 7, 2019 · 0 comments
Open

Twig ~ operator does not compile correctly #123

cpatti97100 opened this issue Jun 7, 2019 · 0 comments
Assignees
Labels

Comments

@cpatti97100
Copy link

From the twig documentation, the ~ operator converts all operands into strings and concatenates them.

Melody compiles this to javascript +, which is fine in case at least one of the operands is a string, but not if they are both eg. numbers.

Both operands should be correctly converted to strings and then be concatenated.

Thanks :)

  • melody version: 1.2.0
@pago pago self-assigned this Jun 25, 2019
@pago pago added the bug label Jun 25, 2019
pago pushed a commit that referenced this issue Jun 25, 2019
Ensure that the binary concatenation operator (~) always produces a string value.
We do that by utilizing the string template syntax instead of the binary plus (+) operator
in the transpiled code.

To make the generated code more efficient and easier to read we'll also collapse
sibling template literals into a single.

fixes #123
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants