Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Components with Multipart Emails (multiple formats) #1670

Open
jaredmoody opened this issue Feb 28, 2023 · 6 comments
Open

Using Components with Multipart Emails (multiple formats) #1670

jaredmoody opened this issue Feb 28, 2023 · 6 comments

Comments

@jaredmoody
Copy link

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.

@joelhawksley
Copy link
Member

@jaredmoody I don't see why we couldn't support this. Mind opening a PR with a failing test to get us started? I'd be happy to pair with you on building this feature, send me an email with your availability: joelhawksley@github.com

@joelhawksley
Copy link
Member

See our work in progress here: #1681.

At this point, it looks like it will be too much work to land this any time soon. I'm tagging this issue as help wanted in case someone would like to step in and give it shot.

@joelhawksley joelhawksley changed the title Using Components with Multipart Emails Using Components with Multipart Emails (multiple formats) Mar 28, 2023
@reeganviljoen
Copy link
Collaborator

@jaredmoody @joelhawksley I am working on adding support for this by checking using request.format to determine the format used in rendering the template

@joelhawksley
Copy link
Member

@reeganviljoen sounds good, let me know what you think of our previous attempt 😄

@reeganviljoen
Copy link
Collaborator

@joelhawksley I looked at the previous attempt and it seemed solid, the only place where I differ is I believe the format should be assumed from the request

@reeganviljoen
Copy link
Collaborator

@jaredmoody I have created a discussion around how view_component handles formats because their are similar feature requests, hopefully this will help shed light on implementing this feature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants