phlex-rails
phlex-rails copied to clipboard
ArgumentError when rendering a partial from a `Phlex::Rails::Layout`
Hi!
I like this change. I needed something like this in the past.
However, it appears to have broken this kind of code:
class ApplicationLayout < Phlex::HTML
include Phlex::Rails::Layout
def view_template
html do
body do
render partial: "tracking" # boom
end
end
end
end
It raises:
ArgumentError:
wrong number of arguments (given 0, expected 1+)
# /Users/kim/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/phlex-rails-1.2.1/lib/phlex/rails/layout.rb:48:in `render'
Originally posted by @Burgestrand in https://github.com/phlex-ruby/phlex-rails/issues/192#issuecomment-2060714585
Worth mentioning is that in this particular case I could fix it by changing to render "tracking", and that this might in some way be related to https://github.com/phlex-ruby/phlex-rails/issues/137?
This should have been covered by the if @_context check, which is essentially saying, “if we’re already rendering something, do the usual behaviour”. It’s because Rails interface for layouts is that they should respond to render, while everything else needs to respond to render_in. So frustrating. 😅
This is fixed in main and v1. It will be in the next release.
🎉