-
Notifications
You must be signed in to change notification settings - Fork 0
Add support for tagged template literals #2
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
Conversation
let x = j`/* https://www.apple.com */` | ||
let x = `/* https://www.apple.com*/` | ||
let x = `/*https://www.apple.com*/` | ||
let x = `/*https://www.apple.com*/` | ||
let x = sql`/*https://www.apple.com*/` | ||
|
||
let x = `\`https://\${appleWebsite}\`` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tsnobip I'm not sure what the ReScript equivalent of
{js|`https://${appleWebsite}`|js}
should be. I tried
`\`https://${appleWebsite}\``
but now the $
isn't escaped in the output anymore. I'm not really sure what the original test case was trying to test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kevinbarabash {js|
is just a unicode string with no string-interpolation, in rescript master, you can just use regular double quotes "
for that
"https://${appleWebsite}"
should do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original had backticks between between the {js|
and |js}
. Wouldn't that make it
"`https://${appleWebsite}`"
of does {js|
does something special with backticks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops sorry my bad, it is indeed
"`https://${appleWebsite}`"
function sql(prim0, prim1) { | ||
return Caml_splice_call.spliceApply(Tagged_template_libJs.sql, [ | ||
prim0, | ||
prim1 | ||
]); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't appear in the output since it isn't used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be a test file that calls the tagged template function as a function call to make sure that this helper is still included in that situation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about this a bit more and it is actually being used because sql
is exported.
I know this is closed, but @kevinbarabash @tsnobip is this something you'd be interested in taking up work on again? Support for tagged template literals would be a great addition to the compiler, and there's currently good chances to get this reviewed in a timely manner given that the activity in the compiler development has increased significantly the last month. |
basically kevinbarabash#2 rebased on master
basically kevinbarabash#2 rebased on master
basically kevinbarabash#2 rebased on master
* support tagged template in rescript and allow to bind to JS tagged templates using @taggedTemplate annotation * Set version to 11.1.0 * add tagged templates to changelog This work was originally based on kevinbarabash#2
This PR is a replacement for rescript-lang/syntax#471. In addition to updating the parser to treat tagged templates as apply nodes, it also updates the frontend to convert those apply nodes (with
ap_tagged_template
set totrue
) to tagged template literals in the JS output.NOTE: This PR depends on rescript-lang#5347.
TODO:
TODO
s that were added by this PR""
in place of{js|
strings and rename it toresStrings.res
or something like that and bring back the original ocamlStrings.ml just without thesql
test case.