Closed blelump closed 7 years ago
Not Galvin, but i might be help. You are currently using pretty diff for beautification, which produces the same results for me. Switching the erb default beautifier to HTML Beautifier
indents correctly for me.
Thanks for helping out @jmenges. I also recommend trying out other beautifiers. Language Config - ERB - Default Beautifier
option in the Atom Beautify package settings.
/cc @prettydiff
Currently, I am not looking at any sort of naming to determine indentation. I am only looking at syntax. 99% of the time this is fine, and ERB is an exception. For instance, in the first example:
<%= content_for :additional_javascript_libraries do %>
<%= javascript_include_tag "a/b" %>
<% end %>
What makes <%= content_for
a start tag that imposes an extra step of indentation where <%= javascript_include_tag
doesn't?
Thanks guys for your response.
@prettydiff , in this case content_for
takes a block of code (do; end
syntax) as an argument. The same rules apply to pure Ruby code and ERB templates are not an exception here.
edit:
OK, finally got it. According to the readme, I've still tried to modify .jsbeautifyrc
, whereas all these options apply straight to Atom config. Perhaps it's due to I've just started to use Atom... :-)
ps. I've seen other issues somewhat related this topic and some of them are related to how RVM (Ruby Version Manager) works, e.g https://github.com/Glavin001/atom-beautify/issues/232 . RVM is usually installed within user environment and its scope is limited to the user shell so it really depends on how one would run Atom.
@blelump your config for .jsbeautifyrc seems is very good. can you share the latest config. you might have solved problem for content_for and do; end as well.
I am looking at adding indentation support for ERB now, but I need something to make it happen. Please list all tags or keywords that could cause an increase in indentation, such as: for
, if
, and do
. Also will tags that cause indentation always be delimited as <%=
? I noticed that ERB has a couple of different delimiters: https://docs.puppet.com/puppet/latest/reference/lang_template_erb.html#tags
@prettydiff : Could Pretty Diff provide an option to change which tags are formatted or not? Similar to unformatted
option: https://github.com/Glavin001/atom-beautify/blob/master/docs/options.md#unformatted
Something to keep in mind, although I'm sure you likely consider that already.
Thanks!
I could provide such an option, but as I understand the issue of this thread it is more about the tags supplying indentation.
I am also unclear on the unformatted
option. Does this option prevent formatting of the tags internals or the tags internals plus everything before its end tag?
Yeah, my comment was somewhat unrelated to this particular issue. More so in general, it reminded me to ask you about Pretty Diff supporting the unformatted
option that JS-Beautify does. The more Pretty Diff support the better! :smiley:
I am also unclear on the unformatted option.
You are correct with:
this option prevent formatting of the tags internals
I have this option added in branch 2.0.4 and will publish soon.
It seems this option/feature was added to Pretty Diff last year. The latest version of Pretty Diff recently landed in Atom Beautify.
Hi Glavin! Thank you for the tool. It seems to be quite useful, as soon as I'll resolve my issues :-) .
I'm trying to format
html.erb
file:After beautification it should look smth like:
whereas it seems that it always drops the indendation, e.g if input is given as
it returns
I've installed
htmlbeautifier
as suggested, however I am not sure it's being used by beautifier. By puttingctrl+alt+b
some magic happens and the result is incorrect. How to debug which beautifier is being used for given type of file?Here's the debug command output:
Atom Beautify - Debugging information
The following debugging information was generated by
Atom Beautify
onSat Jun 27 2015 22:29:12 GMT+0200 (CEST)
.Platform: linux
Versions
Atom Version: 1.0.0
Atom Beautify Version: 0.28.7
Original file to be beautified
Original File Path:
file.html.erb
Original File Grammar: HTML (Ruby - ERB)
Original File Language: ERB
Original File Contents:
Beautification options
Editor Options: Options from Atom Editor settings
Config Options: Options from Atom Beautify package settings
Home Options: Options from
/media/slave/users/rails/.jsbeautifyrc
EditorConfig Options: Options from EditorConfig file
Project Options: Options from
.jsbeautifyrc
files starting from directory...
and going up to rootFinal Options: Final combined options that are used
Package Settings: The raw package settings options
Results
Beautified File Contents:
Logs: