_hyperscript icon indicating copy to clipboard operation
_hyperscript copied to clipboard

slashes break inside backticks

Open russell-hutson-jp opened this issue 2 years ago • 3 comments

@0.9.5 set pdfurl to https://yyy.xxxxxx.com/path/out/${trackingcode}.pdf gives pdfurl as https://yyy.xxxxxx.com/path/out/AB123456789KK.pdf

@0.9.7 set pdfurl to https://yyy.xxxxxx.com/path/out/${trackingcode}.pdf gives pdfurl as https:

russell-hutson-jp avatar Dec 09 '22 15:12 russell-hutson-jp

I have encountered the same. The tokenizer does a lot of (overly aggressive and error prone?) interpreting of the contents of template literals. In this case it sees the // as a comment prefix which leads the parser to discard the rest.

darrinm avatar Dec 17 '22 01:12 darrinm

Can I get some more context on this? I added two regression tests that both pass (raw template eval + in the context of a set)

https://github.com/bigskysoftware/_hyperscript/issues/399

It seems like in some cases we are starting template string parsing in the wrong "mode"

I assume the above code is:

set pdfurl to `https://yyy.xxxxxx.com/path/out/${trackingcode}.pdf`

1cg avatar Dec 19 '22 18:12 1cg

Here's one that breaks

set count 1
set optName to `options_${count}_value`

This produces the string literally options_${count}_value when I would expect options_1_value.

I have to do this as a workaround

set optName to 'options_' + `${count}_value`

Ramblurr avatar Oct 24 '23 09:10 Ramblurr