phlexing icon indicating copy to clipboard operation
phlexing copied to clipboard

Methods called within the ERB template are not generated in the component output

Open marcoroth opened this issue 2 years ago • 2 comments

ERB Input:

<% if some_condition? %>
  <%= "Text" %>
<% end %>

Output:

class Component < Phlex::HTML
  def template
    if some_condition?
      text "Text"
    end
  end
end

Expected output:

class Component < Phlex::HTML
  def template
    if some_condition?
      text "Text"
    end
  end

  private 
  
  # TODO: Implement the `some_condition?` method
  def some_condition?
    super
  end
end

marcoroth avatar Jan 20 '23 17:01 marcoroth

This might be unnecessary since we’ll get a helpful NoMethodError anyway when calling method? anyway.

joeldrapper avatar Jan 23 '23 11:01 joeldrapper

I thought it might be cool to indicate that there's still something missing.

But I updated the example to use super so that we still would get the helpful exception.

marcoroth avatar Jan 23 '23 15:01 marcoroth