Skip to content

Analyze Ruby code in ERB interpolated HTML attributes#88

Merged
marcoroth merged 1 commit intomainfrom
detect-ruby-code-in-interpolated-attributes
Feb 7, 2023
Merged

Analyze Ruby code in ERB interpolated HTML attributes#88
marcoroth merged 1 commit intomainfrom
detect-ruby-code-in-interpolated-attributes

Conversation

@marcoroth
Copy link
Owner

Fixes #68

This works now:

ERB Input:

<div class="<%= @hello %>">Hello</div>

Output:

class HelloComponent < Phlex::HTML
  def initialize(hello:)
    @hello = hello
  end

  def template
    div(class: @hello) { "Hello" }
  end
end

@marcoroth marcoroth merged commit be1511c into main Feb 7, 2023
@marcoroth marcoroth deleted the detect-ruby-code-in-interpolated-attributes branch February 7, 2023 09:52
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 this pull request may close these issues.

ivars and locals used in ERB attribute interpolation are not respected when generating the initialize method

1 participant