开发者

Rails HTML/TEXT UserMailer Templates

开发者 https://www.devze.com 2023-02-09 06:26 出处:网络
Currently for my Rails 3 mailer templates, I need to create an html and text version in the vie开发者_Python百科ws/user_mailer directory.

Currently for my Rails 3 mailer templates, I need to create an html and text version in the vie开发者_Python百科ws/user_mailer directory.

Why is that necessary? Why can't rails look at the html version and automatically format it to a text/plain version?


This is not required. You can simply provide one of those templates. For instance, if you don't need HTML, you can create the TEXT file only.

Likewise, you can provide the HTML template only. Readers will attempts to extract the information. However, if you use HTML, you should provide an alternative TEXT version to make sure the readers won't mess the content of your email.

By the way, Rails doesn't force you to provide both templates.


This question seems to be similar to yours and might be helpful to you:

Graceful degradation/progressive enhancement for Action Mailer templates?

Also, here are some direct links to some gems that help to solve this problem of duplication between html and text mailer templates:

  1. https://github.com/plataformatec/markerb
  2. https://github.com/Mange/roadie
  3. https://github.com/fphilipe/premailer-rails3
0

精彩评论

暂无评论...
验证码 换一张
取 消