I was trying to convert a partial that's used in my mailers to a ViewComponent today, and because the partial is used in a multipart email, it has a plaintext template (_thing.text.erb) as well as an html template (_thing.html.erb). I was surprised I could not define a component with two different template formats, I get the following error:
ViewComponent::TemplateError: More than one template found for Mailers::ThingComponent. There can only be one default template file per component.
Maybe I could workaround by using a variant?
It sure would be nice if this just worked out of the box the way that Rails does with different formats.
I was trying to convert a partial that's used in my mailers to a ViewComponent today, and because the partial is used in a multipart email, it has a plaintext template (_thing.text.erb) as well as an html template (_thing.html.erb). I was surprised I could not define a component with two different template formats, I get the following error:
ViewComponent::TemplateError: More than one template found for Mailers::ThingComponent. There can only be one default template file per component.Maybe I could workaround by using a variant?
It sure would be nice if this just worked out of the box the way that Rails does with different formats.