对 HTML 电子邮件进行预检
为了获得最佳的 HTML 电子邮件传输效果, CSS 应当采用内联方式。这是一个 巨大的痛苦,一个简单的电子邮件通讯很快就变得无法管理。 gem 是一个解决方案。
style 和 link[rel=stylesheet] 标签,并保留现有的内联属性href,src 和 CSS url('') 中的链接gem install premailerrequire 'premailer'
premailer = Premailer.new('http://example.com/myfile.html', warn_level: Premailer::Warnings::SAFE)
# Write the plain-text output (must come before to_inline_css)
File.write "output.txt", premailer.to_plain_text
# Write the HTML output
File.write "output.html", premailer.to_inline_css
# Output any CSS warnings
premailer.warnings.each do |w|
puts "#{w[:message]} (#{w[:level]}) may not render properly in #{w[:clients]}"
end| CSS 属性 | 可用性 |
| -premailer-width | 在 table、th 和 td 元素上可用 |
| -premailer-height | 在 table、tr、th 和 td 元素上可用 |
| -premailer-cellpadding | 在 table 元素上可用 |
| -premailer-cellspacing | 在 table 元素上可用 |
| -premailer-align | 在 table 元素上可用 |
| data-premailer="ignore" | 在 link 和 style 元素上可用。Premailer 将忽略此属性。
暂无开放 Issues,或尚未同步最近议题。