Support for more syntax and better multiline ERB formatting #92
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.
Hi,
First of all, thanks for building
syntax_tree-erb
! It was the closest to what I was looking for, so I forked it and made a few changes. I think you may agree with most (or all?) of them, so I'm letting you know what I did here.My code is slightly hacky in places and I don't fully know what I'm doing, so do let me know if you'd like me to clean something up.
Multiline ERB formatting
Before my change multiline ERB would be formatted more or less like this:
I think whether the version with brackets looks good is subjective, but I have to assume the version without brackets wasn't intended - the alignment is off by the length of
<%=
prefix.One way to improve it may be to use the
erb
plugin together with the no_alignment plugin, which will give something like this:That still doesn't look great though.
What my branch (this PR) does is the following:
It adds more linebreaks, but I much prefer it.
I think it could be a configuration option if you (or other users) prefer the more condensed version.
ERB inside HTML tags
Previous state:
In my branch all of these cases are supported.
when 1, 2
Previous state:
In my branch comma-separated arguments are also supported.
Formatting of keywords in ERB blocks
Previously code like below was possible
In my branch keywords are formatted together with the rest of the Ruby code, so it looks better:
And that's it for now.
Let me know what you think.