-
Notifications
You must be signed in to change notification settings - Fork 25
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
Bug/Feature: Partials not rendered correctly #69
Comments
I poked at this for awhile. The problem is that the format isn't being persisted through the I don't know where or how that value is supposed to be set :( It might be possible to reproduce this without maildown. I think that's a good step, but I don't know of any other template that changes behavior based on format. Basically: I think this is a Rails bug, but I can't prove it's not caused by a maildown monkeypatch. We can access the existing templates Meta thoughtsThe maildown project is hard to understand here's some intermediate steps:
|
@schneems Thanks so much for looking into this. Seems I'm not the only one that found the If I recall, my original investigation found something similar, that the This may be a Rails bug itself but my thinking that it wasn't and it should be fixable is that when rendering partials without But I know there's more to it with Again, I honestly think this is the final feature to round out the functionality of I'm not sure what else I can do here but let me know if there's anything. Would love to get this in there and remove the hacks I've had to use to get around this. Thanks again! 🙏 |
I'm working on cleaning up the project and removing Rails 5 support #70. Github actions are failing when setting up Ruby versions ATM, no clue why :( I think I could reproduce the problem without any monkeypatches. Rails 7 only uses one monkeypatch and it's mostly for convenience to avoid having to call Honestly, this project isn't doing all that much once the branching conditionals for Rails < 5 are removed. It's mostly just using APIs provided via Rails. |
Well, maybe now's the time to do a v4 branch and only support Rails 7+ going forward and include this proper format handling on partials. We're running the latest version of Ruby and Rails if you want some testing done. Keen to help anyway we can and can afford with time allowances, etc. Thanks and Happy New Year! |
Original issue: #53 (comment)
Copying because it's an old one and we have a new reproduction. If someone fixes this in October I'll
hacktober-accepted
label the PR.Reproduction:
From @joshuapinter
I finally got around to creating a simple example app that re-creates the issue of markdown (
.md.erb
) partials not rendering correctly in plain text. You can view the repo here:https://github.com/joshuapinter/maildown_partials_issue
I've included the repro instructions in the README but here they are as well:
Clone the repo and install gems via
bundle
.Run the server via
bundle exec rails s
Navigate to http://localhost:3000/rails/mailers/notifier_mailer/markdown_partial_test in your browser:
By default the HTML format will appear, and it appears correctly.
Click on the format drop down and select "View as plain-text email".
You will see that the partial gets rendered incorrectly as HTML instead of plain text.
To see what it should look like, navigate to http://localhost:3000/rails/mailers/notifier_mailer/non_markdown_partial_test.txt in your browser.
You will see that using two files for formats (
html.erb
andtext.erb
) and not using markdown (md.erb
) via maildown renders the partials correctly for both HTML and plain text.I did this in Rails 6 and Ruby 3 because that's what I had handy.
I hope this is enough to re-open this Issue and take another look. I've spent a few hours trying to figure it out myself and digging into how Rails renders partials but it's a bit over my head.
Let me know if you need anything from my side or if you want me to do some testing.
Rendering emails in markdown is incredible and I feel like this is the missing piece to make it truly clean, DRY and beautiful.
My analysis
How maildown works: It first renders ERB and then runs it through a Markdown parser to generate HTML, or just plain text to deliver the text/plain version. What I think is happening here is that the ERB in the partial is being evaluated as if it's an HTML partial no matter what.
I think there's two paths forward:
The text was updated successfully, but these errors were encountered: