w3c / web-share-target

Web API proposal for receiving shared data
https://w3c.github.io/web-share-target/
Other
191 stars 20 forks source link

url template looks like JS template literals but then isn't #17

Closed kenchris closed 6 years ago

kenchris commented 7 years ago

Why not change

"/share?title={title}&text={text}&url={url}"

into

"/share?title=${title}&text=${text}&url=${url}"

Now they refer to properties on a JS object (JSON)?

mgiuca commented 7 years ago

Hmm, in some sense it's neat to tie this into the same syntax as JS.

On the other hand, this isn't actually the same thing at all. It isn't JavaScript (it's JSON), it isn't the template literal syntax (it doesn't use backticks), and the body of those braces is not allowed to be an arbitrary JavaScript expression, just one of a handful of special names. It might be confusing to use that syntax.

We chose bare braces because they were the simplest syntax that is unambiguous (since braces are completely forbidden in URLs, they unambiguously represent a template parameter). I'm hesitant to change this to match the JS template literal syntax.

kenchris commented 6 years ago

Ok, makes sense