Open daniel-nagy opened 5 months ago
Have you considered using triple back ticks?
Yes, please see existing issues. Note that the code you've given is in fact already legal and so cannot be used.
Maybe I'm wrong, but it doesn't seem like this proposal would support the case where you want all lines to be indented by some amount.
True, this proposal aims to solve dedenting, not indenting.
True, this proposal aims to solve dedenting, not indenting.
Wouldn't it be better if it solved both?
Depends on what additional complexity is required to do so, and how valuable we think doing so is. Personally I don't think indenting is very valuable so I am not inclined to incur any additional complexity to enable it.
Personally I don't think indenting is very valuable so I am not inclined to incur any additional complexity to enable it.
I have run into use cases where I needed to control indenting.
Note that the code you've given is in fact already legal and so cannot be used.
Can you elaborate more on this? When I test the code I provided I get an error
Uncaught TypeError: "" is not a function
Even if the syntax is lexically valid, I don't think it has any semantic meaning.
See previous issues.
Oof, ok
I started a list of potential ECMAScript proposals and this was on my list 😄.
I think the README does a pretty good job of explaining why this feature is necessary. However, I had a different syntax in mind. Have you considered using triple back ticks? e.g.
I think this would behave like multiline strings in Elixir. Sepcifically, the indentation of the last ``` would determine where the indentation starts. I call these lexically indented template literals.
Maybe I'm wrong, but it doesn't seem like this proposal would support the case where you want all lines to be indented by some amount. Specifically, this criteria
e.g.
would result in
but maybe I acutally want the starting indentation
With this proposal, that doesn't seem possible.
Another benefit of triple back ticks, in my opinion, is that they are more ergonomic with tagged template literals. I can lift any existing tagged template literal by simply replacing single backticks with triple back ticks, e.g.
vs