zombocom / maildown Goto Github PK
View Code? Open in Web Editor NEWWrite your ActionMailer email templates in Markdown, send in html and plain text
License: MIT License
Write your ActionMailer email templates in Markdown, send in html and plain text
License: MIT License
With mail_view this markdown:
## You're almost there <%= @resource.username.capitalize %>!
renders correctly in html but in text just shows as is
## You're almost there <%= @resource.username.capitalize %>!
What do I do wrong? Using rails 4
Error:[rake --tasks] rake aborted!
NameError: undefined method `extract_handler_and_format_and_variant' for class `ActionView::OptimizedFileSystemResolver'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/maildown-3.3.0/lib/maildown/ext/action_view.rb:7:in `<class:OptimizedFileSystemResolver>'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/maildown-3.3.0/lib/maildown/ext/action_view.rb:6:in `<module:ActionView>'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/maildown-3.3.0/lib/maildown/ext/action_view.rb:5:in `<main>'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:100:in `register'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/zeitwerk-2.5.1/lib/zeitwerk/kernel.rb:35:in `require'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/maildown-3.3.0/lib/maildown.rb:24:in `block in <main>'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activesupport-7.0.0/lib/active_support/lazy_load_hooks.rb:71:in `class_eval'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activesupport-7.0.0/lib/active_support/lazy_load_hooks.rb:71:in `block in execute_hook'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activesupport-7.0.0/lib/active_support/lazy_load_hooks.rb:61:in `with_execution_control'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activesupport-7.0.0/lib/active_support/lazy_load_hooks.rb:66:in `execute_hook'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activesupport-7.0.0/lib/active_support/lazy_load_hooks.rb:52:in `block in run_load_hooks'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activesupport-7.0.0/lib/active_support/lazy_load_hooks.rb:51:in `each'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activesupport-7.0.0/lib/active_support/lazy_load_hooks.rb:51:in `run_load_hooks'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/actionview-7.0.0/lib/action_view/base.rb:276:in `<class:Base>'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/actionview-7.0.0/lib/action_view/base.rb:141:in `<module:ActionView>'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/actionview-7.0.0/lib/action_view/base.rb:12:in `<main>'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:100:in `register'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/zeitwerk-2.5.1/lib/zeitwerk/kernel.rb:35:in `require'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/will_paginate-3.3.1/lib/will_paginate/view_helpers/action_view.rb:149:in `<module:ActionView>'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/will_paginate-3.3.1/lib/will_paginate/view_helpers/action_view.rb:23:in `<module:WillPaginate>'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/will_paginate-3.3.1/lib/will_paginate/view_helpers/action_view.rb:4:in `<main>'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:100:in `register'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/zeitwerk-2.5.1/lib/zeitwerk/kernel.rb:35:in `require'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/simple_discussion-1.3.0/lib/simple_discussion/will_paginate.rb:1:in `<main>'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:100:in `register'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/zeitwerk-2.5.1/lib/zeitwerk/kernel.rb:35:in `require'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/simple_discussion-1.3.0/lib/simple_discussion.rb:9:in `<main>'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:100:in `register'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/zeitwerk-2.5.1/lib/zeitwerk/kernel.rb:35:in `require'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bundler-2.2.33/lib/bundler/runtime.rb:60:in `block (2 levels) in require'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bundler-2.2.33/lib/bundler/runtime.rb:55:in `each'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bundler-2.2.33/lib/bundler/runtime.rb:55:in `block in require'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bundler-2.2.33/lib/bundler/runtime.rb:44:in `each'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bundler-2.2.33/lib/bundler/runtime.rb:44:in `require'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bundler-2.2.33/lib/bundler.rb:175:in `require'
/home/maildown_test/Documents/webapps/my-app/config/application.rb:7:in `<top (required)>'
/home/maildown_test/Documents/webapps/my-app/Rakefile:4:in `require_relative'
/home/maildown_test/Documents/webapps/my-app/Rakefile:4:in `<top (required)>'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/rake_module.rb:29:in `load'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/rake_module.rb:29:in `load_rakefile'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/application.rb:710:in `raw_load_rakefile'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/application.rb:104:in `block in load_rakefile'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/application.rb:103:in `load_rakefile'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/application.rb:82:in `block in run'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/application.rb:80:in `run'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
/home/maildown_test/.rbenv/versions/3.0.2/bin/rake:23:in `load'
/home/maildown_test/.rbenv/versions/3.0.2/bin/rake:23:in `<top (required)>'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bundler-2.2.33/lib/bundler/cli/exec.rb:58:in `load'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bundler-2.2.33/lib/bundler/cli/exec.rb:58:in `kernel_load'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bundler-2.2.33/lib/bundler/cli/exec.rb:23:in `run'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bundler-2.2.33/lib/bundler/cli.rb:479:in `exec'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bundler-2.2.33/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bundler-2.2.33/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bundler-2.2.33/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bundler-2.2.33/lib/bundler/cli.rb:31:in `dispatch'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bundler-2.2.33/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bundler-2.2.33/lib/bundler/cli.rb:25:in `start'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bundler-2.2.33/exe/bundle:49:in `block in <top (required)>'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bundler-2.2.33/lib/bundler/friendly_errors.rb:103:in `with_friendly_errors'
/home/maildown_test/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bundler-2.2.33/exe/bundle:37:in `<top (required)>'
/home/maildown_test/Documents/webapps/my-app/bin/bundle:3:in `load'
/home/maildown_test/Documents/webapps/my-app/bin/bundle:3:in `<main>'
Hi. I'm seeing a problem with Thread.current[:maildown_markdown_engine_block].call(string)
(Source) resulting in a undefined method 'call' for nil:NilClass
. Could I get some advice on how to debug this issue, I'd be happy to prepare a PR?
Using: Ruby 2.0.0, Rails 4.0.0, Puma App Server 2.5.1
I just tried installing the gem by adding the following to Gemfile
gem 'maildown'
That worked except I'm already using Redcarpet in my project so I wanted to configure the markdown renderer like is shown in the Readme, but I got an error when I put the code sample from the Readme in an initializer.
Looking at the gem version I saw that it's still 0.0.1 so I pointed my Gemfile to the Github repo and everything worked.
I'd love to see a new version of the gem that's in sync with the Readme.
I'm looking forward to using this Gem with a Rails 3.2.11 application. Once added to the app, I get an error
gems/maildown-0.0.1/lib/maildown/ext/action_mailer.rb:2:in <top (required)>': undefined method
default_formats' for #Class:0x0000010291f908 (NoMethodError)
I don't see default_formats as a method for ActionMailer::Base or anywhere in ActionMailer.
I don't know enough about the inner workings of Rails to help beyond that. Does the Gem work with 3.2.X?
The gemspec
seems to indicate that actionmailer greater than 4.0.0 is supported, while the readme says that support is for Rails 5.0 +. Looking through some of the issues it seems at least some people use (or used) this with Rails 4+. Would love some clarification as this.
Ex:
class UserMailer < ActionMailer::Base
layout 'general_mailer'
default from: "*** <[email protected]>"
def welcome(uid)
@user = User.find(uid)
mail to: @user.email, subject: 'Welcome to PathSource!'
end
end
Run UserMailer.welcome(1).deliver will not render the layout at all. But layout file general_mailer.html.erb does exist.
When I debug into the source, I find on this line https://github.com/rails/rails/blob/master/actionview/lib/action_view/renderer/template_renderer.rb#L86 it raise ActionView::MissingTemplate, but return true on https://github.com/rails/rails/blob/master/actionview/lib/action_view/renderer/template_renderer.rb#L90.
So it only search for md format layout. I don't know why it happens.
I use maildown
with the redcarpet
renderer, but because maildown
depends on kramdown
bundler insists on installing both gems. As far as I am aware this is ultimately a shortcoming of bundler
itself: It does not support optional dependencies or allows me to override dependencies.
As far as I know the "normal" way of handling this is to not specify these "sort of optional" dependencies at the gem level. Rails for example does not specify all sorts of database drivers, although at least one of them will have to be used. Would you consider to do the same for maildown?
Related to #5, which defines the default Markdown parsers for multithreaded environments.
Trying to customize the Markdown renderer in a Rails initializer doesn't seem to work, though. No matter what is set there, the .md.erb
templates are still parsed with Kramdown.
I expect the issue to be related to where this renderer block gets memoized.
@schneems If you could give a hint on how you'd "memoize/store" this custom renderer/config, I would be happy to prepare a PR.
Environment: Ruby 2.0, Rails 4.0.0, Maildown 1.0.2, Puma 2.5.1 with no special config except a minimum level of threads > 1
When using maildown email layouts seem to be ignored.
Steps to reproduce:
Create mailer eg.
class GeneralMailer < ActionMailer::Base
layout "email"
def example()
mail(from: "[email protected]", to: "[email protected]", subject: "test")
end
end
Then in app/veiws/layouts/email.html
<h1> Header </h1>
<%= yield %>
<div class="footer">Footer</div>
Then create example.md.erb
with some content.
The moment you create the email it'll render without layout.
This is a weird one (sorry). Adding the Maildown gem breaks local email delivery into tmp/mails
. Removing the gem and they start saving again. It doesn't cause any issues in production, and the dev /rails/mailers
preview works fine. So real email sending and rendering is fine, but local delivery breaks.
The only monkeypatch Maildown does to Rails is in lib/maildown/ext/action_mailer.rb and that's only 17 LOC. So I went through commenting and uncommenting bits of that file until I found the culprit is line 3
mail_view_klass = ActionMailer::Base.view_context_class
Which is weird as that barely does anything. The method view_context_class
is included from several files deep with Rails and has some funky stuff in it like an anonymous class. But maybe the issue is nothing to do with that method; could it be a load order / autoloading thing?
I'm at a bit of a loss, any thoughts?
There is an issue with a Rails 7 and this library #59 to help work on it we should add a failing Rails 7 test.
This task depends on #63
Also, I'm looking for help maintaining this project in the future. I ask anyone interested to please send a PR and mention that you're interested in helping. You can email me if you've previously had a commit merged in this project.
A maintainer will gain commit access and deploy access on rubygems if they don't have it already. A maintainer will be expected to:
I'm not sure if the mail
method with block is from Rails 4.0 or Rails 4.1. But the bug is when I write code like this:
def example_1
mail to: '[email protected]' do |format|
format.text { render plain: 'aaa' }
end
end
The whole block is ignored and if I don't define a 'example_1.text.erb', an error is raised to tell me 'example_1' template is not found.
After some search I find why this happens and will submit a PR to solve it soon.
There is a fix reported in #59.
Depends on:
Though all of these can be done at the same time if it's easier.
Also, I'm looking for help maintaining this project in the future. I ask anyone interested to please send a PR and mention that you're interested in helping. You can email me if you've previously had a commit merged in this project.
A maintainer will gain commit access and deploy access on rubygems if they don't have it already. A maintainer will be expected to:
Hi,
with this gem is possible to use markdown text stored in db?
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
and text.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.
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:
I have the following code:
class UserMailer < ActionMailer::Base
default template_path: 'mailers/user'
layout 'mailers/layouts/default'
def my_mailer
mail(subject: 'Hello world').deliver
end
end
And views/mailers/user/my_mailer.md.erb
along with views/mailers/layouts/default.html.erb
and views/mailers/layouts/default.text.erb
.
I would expect those layouts
to wrap my templates, but it actually doesn't.
It should, shouldn't it? Any idea why? If I have time to investigate on this, any tip on where I should start looking at?
Also, I'm looking for help maintaining this project in the future. I ask anyone interested to please send a PR and mention that you're interested in helping. You can email me if you've previously had a commit merged in this project.
A maintainer will gain commit access and deploy access on rubygems if they don't have it already. A maintainer will be expected to:
When I try render partials with maildown, the rendered partial show as text not html.
In specific, I want add footer with markdown format in mailer layout.
app/views/layouts/mailer.html.erb
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8;"/>
</head>
<body>
<%= yield %>
<%= render partial: "mailer/shared/footer" %>
</body>
</html>
and, this is footer
app/views/mailer/shared/_footer.en.md.erb
-----------------------------------------------
This is Footer in English
The result is:
body content
<hr /> <p>This is Footer in English</p>
Any Idea?
I'm working on an application that has a regular mailer.rb file in the app/mailers directory, and also has a second mailer called notification_mailer.rb, which inherits from mailer class
class NotificationMailer < Mailer
When emails are sent through the normal mailer, the css is rendered inline into the layout like it should and the html rules are applied correctly. When emails are sent through the custom notification_mailer.rb, the css does not render inline to the html and no html is rendered, and the stylesheet tag is still in the header in the source on those emails, on the ones that rendered inline they did not.
I'm standardizing all zombocom projects on GitHub actions since circle has proven to be cumbersome. All projects have been converted except those that depend on needing to test multiple versions of Rails.
Also, I'm looking for help maintaining this project in the future. I ask anyone interested to please send a PR and mention that you're interested in helping. You can email me if you've previously had a commit merged in this project.
A maintainer will gain commit access and deploy access on rubygems if they don't have it already. A maintainer will be expected to:
I looked into what has caused the bug ruby/did_you_mean#102. One thing I noticed is that in the maildown gem, the kramdown
gem is lazily loaded on the fly, which adds a handful of constants dynamically. In an extreme condition, this may cause a race condition. Consider the following scenario where a Sidekiq instance runs two threads (workders) that attempt to run an email delivery job:
Thread 1 | Thread 2 |
---|---|
calls MarkdownEngine.default_html_block |
- |
- | calls MarkdownEngine.default_html_block |
attempts to require 'kramdown' for the first time |
- |
evaluates the line that adds a Kramdown constant but doesn't reach the line 74 that adds Kramdown::Document |
- |
- | evaluates unless defined? Kramdown (now evaluates to unless true ) |
- | attempts to call html_block.call on the proc that has a reference to the Kramdown::Document that does not exist yet |
In this scenario, the thread 2 would raise a NameError
because the Kramdown
constant is loaded but the Kramdown::Document
is not. Also, it would only occur once after a cold reboot since the constant would be available once it's loaded by the thread 1.
I wasn't sure what fixes you'd prefer, so just wanted to bring this up. Thanks!
Is it possible to release a new version based on the current master?
It would be nice if there was a way to filter out some (but not all) of the Markdown syntax from the plain text that gets sent in the mail. For example:
## This is a call to action
Please [click here](http://example.com) to learn more.
* Reasons why
* Reasons why
* Reasons why
might become
This is a call to action
Please click here: http://example.com to learn more.
* Reasons why
* Reasons why
* Reasons why
It's a subtle thing, and it would take some design thinking to ensure that we don't strip away too much of the meaning (inline stuff like bold and italic would need to remain, I think) but it could make the text reading experience better.
Or, am I missing something, and this is already happening? I have used this in a couple of projects in the past, and it always seemed to me that the raw Markdown was being served (with its ERB context filled in, naturally).
Thoughts?
This gem is really good, but.. how to user a layout to render the content within?
we have
/layouts/email.html.haml
but this email is not used by maildown, how to get it to load the html email with this layout?
Notice the README hasn't been updated for Rails 5. Interested in using this in our project, but worried about bugs not being fixed.
I came across the block not being forwarded bug and see that it has been fixed. Could you please release a new version with that fix? Thanks.
The Markdown views are run through Kramdown (et al) for rendering to HTML format, but for Text format the original Markdown is returned unprocessed.
This makes sense insofar as Markdown is already nicely readable text, but Kramdown provides some desirable options to transform Markdown. Specifically, I put <style>
tags in my view / template then use Roadie to correctly inline that in the HTML, but I want to strip the style tags from the Markdown.
Like all good Rubyists, I monkeypatched it in config/initializers/maildown.rb
require "maildown"
module Maildown
class Md
def to_text
Kramdown::Document.new(string).tap(&:to_remove_html_tags).to_kramdown
end
end
end
To ship this officially in the gem the API for supplying an custom Markdown renderer would need to change slightly. There would also have to be a way to specify which options you actually want to use.
Perhaps that's more complexity than it's worth. Perhaps just making this a "well documented monkeypatch" would suffice, an orangutangpatch if you will. Plus some care not to change the to_text
api.
You may not consider this a bug so feel free to close and anyone searching will find the snippet.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.