Description
(Apologies - not sure if the issue is with phlex-rails or phlex).
I just updated from 2.0.2 to 2.1.x and the way I was doing slots has broken - now I get a double-render of each component.
I built a slotted
component, based on the upgrading to v2 docs:
class Components::Slotted < Components::Base
def before_template(&)
vanish(&)
super
end
end
Then descendants of these work something like this:
class Components::Layout < Components::Slotted
def page_header(&contents) = @page_header = contents
def view_template(&)
# some stuff
header { @page_header&.call }
main(&)
# more stuff
end
end
Which is then used as:
Components::Layout() do |layout|
layout.page_header do
h1 { "See below" }
end
div do
h2 { "Exciting things here" }
end
end
However, since moving to 2.1.x, each layout gets rendered twice - at a guess, even though vanish
is called in before_template
, it's still outputting the buffer.
I notice in the yielding section of the docs, it uses vanish
in the view_template
itself - is that the preferred way to do it now?
Metadata
Metadata
Assignees
Labels
No labels