I would find treating ${}
as if nothing was there a little weird.
> tag = parts => console.log(parts)
> tag`a${2}b${}c`
[ 'a', 'b', 'c' ] // expected result
[ 'a', 'bc' ] // actual result
There are some other options to solve the specific example that was originally brought up, for example, you can just concatenate raw strings together as follows:
const r = String.raw
const template = (
r`This is ` +
r`in a ` + // A comment
r`line.`
);
template === 'This is in a line.';
Some more complicated template tags will already support comments inside the template string. e.g. a css
tag should support CSS-style comments.
As for wanting whitespace/comment support in regular expressions, check out this thread that's seeking to add a verbose flag for regular expressions, to provide this kind of support.
None of these things help with the general problem, but can help out in a handful of specific situations.