百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
P

premailer

> 前端框架
开源

对 HTML 电子邮件进行预检

2.4K stars0 点赞4 次浏览
访问官网GitHub

工具介绍

对 HTML 电子邮件进行预检

Premailer README()

这是什么?

为了获得最佳的 HTML 电子邮件传输效果, CSS 应当采用内联方式。这是一个 巨大的痛苦,一个简单的电子邮件通讯很快就变得无法管理。 gem 是一个解决方案。

  • CSS 样式被转换为内联样式属性
  • 检查 style 和 link[rel=stylesheet] 标签,并保留现有的内联属性
  • 相对路径会转换为绝对路径
  • 检查 href,src 和 CSS url('') 中的链接
  • 会检查 CSS 属性是否符合电子邮件客户端的功能
  • 基于电子邮件标准项目的指南
  • 创建 纯文本版本 (可选)

安装

bash
gem install premailer

示例

ruby
require '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· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rubycssinlinemailnokogiri

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类前端框架
定价开源

> 相关工具

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架