Closed aslushnikov closed 5 years ago
Thanks. Will fix that.
@allada already went ahead and created this PR: https://github.com/ndparker/rjsmin/pull/10
Ok, I've added a feature branch here: https://github.com/ndparker/rjsmin/tree/template-strings, incorporating the suggestions from https://github.com/ndparker/rjsmin/pull/10 plus some minor changes plus C changes.
HOWEVER. It's still wrong. First thing is, that template strings allow for literal newlines (fix should be easy), second - I still need to find out if template strings can be nested. If yes, we're kinda screwed :/
Yes, template strings can be nested. For example
`x${`y`}x`
Evaluates to "xyx"
Yes, I've read the spec in the meantime. This is the worst idea ever. The question is, however, how to fix this. No regex can match that. All ways to fix that I can imagine either are restrictive, or require bigger changes.
Having support for template strings that don't have an embedded backticks would still be a significant improvement. Don't let the perfect be the enemy of the good.
My code uses template strings extensively that have embedded newlines (but not backticks) to construct frontend templates for Vue.
@ndparker Any issue with simply merging the template-strings
branch you have now? If I read its tests correctly it already handles newlines, just (presumably) not embedded backticks.
Anything new here?
@davidfstr Sadly, it doesn't handle newlines
This has finally been fixed in Release 1.1.0. We currently have support for non-nesting template literals. It's a start...
I'll close thise PR for now.
Consider feeding the following javascript to rjsmin:
rjsmin
strips the spaces inside the string, but it shouldn't.