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:
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.