Action Mailer模板的平滑降级/渐进增强? [英] Graceful degradation/progressive enhancement for Action Mailer templates?
问题描述
是否存在一些让我们只为Rails 3邮件程序编写 .html.erb
模板的宝石或技术,并通过剥离 text / plain
版本,而不是每个部分都创建两次?
Is there some gem or technique that will let us write only .html.erb
templates for our Rails 3 mailers, and gracefully degrade them by stripping HTML tags for the text/plain
version, rather than having to create each partial twice?
Google严重让我失望,所以我必须
Google is seriously failing me, so I must be searching for the wrong terms.
推荐答案
看看 premailer 。
通常,这不是一个简单的问题。如果我们能够编写语义html标记,然后检测意图并将html转换为看起来合理的纯文本,可能会更容易。
In general, this is not an easy problem. It might be easier if we were able to write semantic html markup and then it'd be easier to detect intent and convert the html into reasonable looking plain text.
您的html电子邮件面向的是广泛的受众,其中充满了各种各样的骇客,使布局可以在多个电子邮件客户端中使用。这种肮脏的标记将使生成美观的纯文本变得更加困难。
But assuming your html emails are intended for a wide audience, it's full of all sorts of hacks that make the layout work in multiple email clients. This sort of dirty markup will make it harder to generate good looking plain text.
另一个问题是无法清楚地转换为文本的内容。例如,显示单击此处的链接在文本中看起来会很有趣。
Another issue are things that won't clearly translate into text. Links that say "click here", will look funny in text, for example.
这篇关于Action Mailer模板的平滑降级/渐进增强?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!