ECR: support removing leading indentation and trailing newline #2991
+224
−25
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #2980
This is an alternative implementation to #2985
@beno I hope you don't mind I decided to try to implement this, but I think the needed changes were really few, and there's no need to introduce more classes nor use regex for this. To do this one just has to look at at most one token ahead, and check if its string value needs to be adjusted. Please check the code, I might have made a mistake or maybe I didn't implement it correctly (I tried a few templates and they seemed to work exactly like ERB).
This now supports all of ERB idioms, as you can see in the specs. Additionally, one can also use
<%-= ... %>
, which removes leading indentation from it, and I guess because of how it's done this also works for<%-# ... %>
.