erb-formatter
erb-formatter copied to clipboard
Encoding issues?
Hi,
First of all: Thank you for this awesome tool. I love how easy it was to setup and how great it works and formats!
Just a small problem: As soon as I add any German umlauts (ä, ö, ü) or the ß character to a file, the formatter fails:
Command failed: bundle exec erb-format --stdin-filename "/Users/till/Sites/tftw-pend/app/views/subscription_mailer/activation.html.erb" --print-width 100
bundler: failed to load command: erb-format (/Users/till/.asdf/installs/ruby/3.2.2/bin/erb-format)
/Users/till/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/erb-formatter-0.7.1/lib/erb/formatter.rb:98:in `gsub!': invalid byte sequence in US-ASCII (ArgumentError)
@source.gsub!(ERB_PLACEHOLDER) { |tag| build_uid[].tap { |uid| pre_placeholders[uid] = tag } }
^^^^^^^^^^^^^^^
from /Users/till/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/erb-formatter-0.7.1/lib/erb/formatter.rb:98:in `initialize'
from /Users/till/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/erb-formatter-0.7.1/lib/erb/formatter/command_line.rb:101:in `new'
from /Users/till/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/erb-formatter-0.7.1/lib/erb/formatter/command_line.rb:101:in `block in run'
from /Users/till/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/erb-formatter-0.7.1/lib/erb/formatter/command_line.rb:97:in `each'
from /Users/till/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/erb-formatter-0.7.1/lib/erb/formatter/command_line.rb:97:in `run'
from /Users/till/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/erb-formatter-0.7.1/exe/erb-format:5:in `<top (required)>'
from /Users/till/.asdf/installs/ruby/3.2.2/bin/erb-format:25:in `load'
from /Users/till/.asdf/installs/ruby/3.2.2/bin/erb-format:25:in `<top (required)>'
from /Users/till/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.12/lib/bundler/cli/exec.rb:58:in `load'
from /Users/till/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.12/lib/bundler/cli/exec.rb:58:in `kernel_load'
from /Users/till/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.12/lib/bundler/cli/exec.rb:23:in `run'
from /Users/till/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.12/lib/bundler/cli.rb:492:in `exec'
from /Users/till/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.12/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
from /Users/till/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.12/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
from /Users/till/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.12/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
from /Users/till/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.12/lib/bundler/cli.rb:34:in `dispatch'
from /Users/till/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.12/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
from /Users/till/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.12/lib/bundler/cli.rb:28:in `start'
from /Users/till/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.12/exe/bundle:45:in `block in <top (required)>'
from /Users/till/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.12/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
from /Users/till/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.12/exe/bundle:33:in `<top (required)>'
from /Users/till/.asdf/installs/ruby/3.2.2/bin/bundle:25:in `load'
from /Users/till/.asdf/installs/ruby/3.2.2/bin/bundle:25:in `<main>'
Is there any way I can set the encoding for the formatter to UTF-8? Maybe via a command line parameter? My files should all be UTF-8 encoded (vscode shows this, but also tripple ensured by saving again with enforced utf-8 encoding.)
Thank you, any help is appreciated!
Hi, i have same issue with cyrillic words in code
@t1ll @Pash-tet Can you send me some failing ERB sample files failing? I'd like to add them to the spec suite
@elia yes, of course, here example with long line )
<%= form_with model: model, url: path, method: :patch do |f| %>
<%= f.select :type, [["не выбрано", nil], %w[Тип1 type1], %w[Тип2 type2], %w[Тип3 type3], %w[Тип4 type4], %w[Тип5 type5]], {}, { class: "select" } %>
<%= f.submit "Сохранить" %>
<% end %>
@elia absolute, happy to share the file. Added "txt" extension to make the upload here work