-
I'm not sure is this a normal behavior or bug. Here is what I have: - # somewhere in app/views/layouts/application.html.haml
= render Header.new do |c|
- c.logo
- c.navigation_link('link', 'url')
- c.navigation_link('link 2', 'url2') class Header < ViewComponent::Base
renders_one :logo, Header::Logo
renders_many :navigation_links, Header::NavigationLink
end - # app/view_components/header.html.haml (markup is omitted)
= logo
- navigation_links.each do |link|
= link class Header::Logo < ViewComponent::Base
def call
'logo' # markup is omitted too. It's just some static content
end
end
- # somewhere in app/views/layouts/application.html.haml
= render Header.new do |c|
- c.logo(1, 2, 3)
... it will be rendered, no matter what params are passed and even if technically Is this normal behavior or bug? IMO if we call |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
This is normal behavior, but I agree with you that it's unintuitive. In the meantime, you can define a method I'll verify that this is the case and update this answer soon. |
Beta Was this translation helpful? Give feedback.
This is normal behavior, but I agree with you that it's unintuitive.
In the meantime, you can define a method
logo
on your component that returns the component you want to render in the slot, and it ought to work in the same way so long as you call it in a<%= %>
tag.I'll verify that this is the case and update this answer soon.