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

Remove interpolated strings #92

Closed
jeparlefrancais opened this issue May 2, 2023 · 1 comment · Fixed by #156
Closed

Remove interpolated strings #92

jeparlefrancais opened this issue May 2, 2023 · 1 comment · Fixed by #156
Labels

Comments

@jeparlefrancais
Copy link
Contributor

jeparlefrancais commented May 2, 2023

Add rule to remove interpolated strings. Simple strings can be converted to string expressions:

Examples:

return `...`

Converts into:

return "..."

More complex interpolated strings can be a chain of concatenation

return `...{true}`

Converts into:

return "..." .. tostring(true)
@jeparlefrancais
Copy link
Contributor Author

I did some research and while it is not very documented, the closest translation of interpolated strings seem to be with %* in string.format call.

It would probably be useful to support generating string.format using %s and tostring calls for Lua environments that don't have %*.

So for an input like:

return `object = {object} ({description})`

It can generate code using %*:

return string.format("object = %* (%*)", object, description)

It can generate code using %s:

return string.format("object = %s (%s)", tostring(object), tostring(description))

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

Successfully merging a pull request may close this issue.

1 participant