Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supporting string interpolation in attribute names #5

Open
nerfologist opened this issue Jul 8, 2021 · 0 comments · May be fixed by #7
Open

Supporting string interpolation in attribute names #5

nerfologist opened this issue Jul 8, 2021 · 0 comments · May be fixed by #7

Comments

@nerfologist
Copy link

nerfologist commented Jul 8, 2021

Hello, I have an ERB fragment such as the following, which is a common pattern to pass values to sidecar Javascript in Stimulus:

<div data-<%= controller_name %>-someattribute-value="<%= attribute_value %>"></div>

And I run it through erb-linter, I get the following error:

#<Thread:0x00007f82d9299d58 /Users/marco/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/erb-linter-0.2.0/lib/erb/linter/checker.rb:26 run> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
        6: from /Users/marco/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/erb-linter-0.2.0/lib/erb/linter/checker.rb:30:in `block (3 levels) in check_files'
        5: from /Users/marco/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/erb-linter-0.2.0/lib/erb/linter/converter.rb:37:in `erb2html'
        4: from /Users/marco/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/erb-linter-0.2.0/lib/erb/linter/converter.rb:37:in `each'
        3: from /Users/marco/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/erb-linter-0.2.0/lib/erb/linter/converter.rb:37:in `gsub!'
        2: from /Users/marco/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/erb-linter-0.2.0/lib/erb/linter/converter.rb:48:in `block in erb2html'
        1: from /Users/marco/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/erb-linter-0.2.0/lib/erb/linter/converter.rb:48:in `map!'
/Users/marco/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/erb-linter-0.2.0/lib/erb/linter/converter.rb:66:in `block (2 levels) in erb2html': Don't know how to process attribute: "data-<%= controller_name %>-someattribute-value=\\"<%= attribute_value %>\\"" (RuntimeError)
rails aborted!
Don't know how to process attribute: "data-<%= controller_name %>-someattribute-value=\"<%= attribute_value %>\""

Is it possible to support string interpolation in attribute names? Rails seems to manage it properly.

@nbelzer nbelzer linked a pull request Apr 25, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant