I have a SectionComponent Class as follow :
class SectionComponent < ViewComponent::Base
def initialize(..)
...
end
end
And a matching section_component.html.erb file.
It works perfectly fine.
Though I want to render a different template depending on a keyworded argument in the intialize method. And I can't figure out how to render a different template.
I have tried to explicitly render a different template (without playing with the intialize method yet):
def render
render_template(:section_details_component, template_path: "section_details_component.html.erb")
end
But each time my server complains it can't find the template. Actually the render block seems to never be hit. Is there a specific syntax to adding a different template ? Or maybe a workaround ?
Otherwise I will write as many components as I have templates...