komponent
komponent copied to clipboard
Nested yields
I'm trying to write a Komponent with a method that renders another Komponent but something seems to be up with how the blocks are passed around.
I have built a repro case at https://github.com/aldhsu/komponent-nested-yields.
Expected
Expect this:
<%# index.html.erb %>
<%= c "foo" do |foo| %>
<%= foo.bar do %>
Hello
<% end %>
<% end %>
<%# _foo.html.erb %>
<div class="foo">
<%= yield self %>
</div>
#foo_component.rb
module FooComponent
extend ComponentHelper
def bar(&block)
component("bar", &block)
end
end
<%# _bar.html.erb %>
<div class="bar">
<%= yield %>
</div>
To output:
<div class="foo">
<div class="bar">
Hello
</div>
</div>
Actual
<div class="foo">
Hello
<div class="bar">
Hello
</div>
</div>
I'm not sure I entirely understand how the capture is supposed to work in this case so I don't know where to start looking. Basically I'm wrapping this behaviour:
<%= c "foo" do %>
<%= c "bar" do %>
Hello
<% end %>
<% end %>
I think this issue is similar to #83, that has been handled with a workaround. Since it's the second time this issue is raised, I think we should investigate further.