在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:premailer/premailer开源软件地址:https://github.com/premailer/premailer开源编程语言:Ruby 91.6%开源软件介绍:Premailer READMEWhat is this?For the best HTML e-mail delivery results, CSS should be inline. This is a huge pain and a simple newsletter becomes un-managable very quickly. This script is my solution.
InstallationInstall the Premailer gem from RubyGems. gem install premailer or add it to your Examplerequire 'premailer'
premailer = Premailer.new('http://example.com/myfile.html', :warn_level => Premailer::Warnings::SAFE)
# Write the plain-text output
# This must come before to_inline_css (https://github.com/premailer/premailer/issues/201)
File.open("output.txt", "w") do |fout|
fout.puts premailer.to_plain_text
end
# Write the HTML output
File.open("output.html", "w") do |fout|
fout.puts premailer.to_inline_css
end
# Output any CSS warnings
premailer.warnings.each do |w|
puts "#{w[:message]} (#{w[:level]}) may not render properly in #{w[:clients]}"
end AdaptersPremailer's default adapter is nokogiri if both nokogiri and nokogumbo are included in the Gemfile list. However, if you want to use a different adapter, you can choose to. There are three adapters in total (as of premailer 1.10.0)
hpricot adapter removed due to its EOL, please use
Premailer::Adapter.use = :nokogiri_fast Ruby CompatibilitySee .github/workflows/actions.yml for which ruby versions are tested. JRuby support is close, contributors are welcome. Premailer-specific CSSPremailer looks for a few CSS attributes that make working with tables a bit easier.
Each of these CSS declarations will be copied to appropriate element's attribute. For example table { -premailer-cellspacing: 5; -premailer-width: 500; } will result in <table cellspacing='5' width='500'> Configuration optionsThe behavior of Premailer can be configured by passing options in the initializer. For example, the following will accept HTML from a string and will exclude unmergeable css from being added to the premailer = Premailer.new(html_string, with_html_string: true, drop_unmergeable_css_rules: true) See here for a full list of the available options. ContributionsContributions are most welcome. Premailer was rotting away in a private SVN repository for too long and could use some TLC. Fork and patch to your heart's content. Please don't increment the version numbers, though. A few areas that are particularly in need of love:
Credits and codeThanks to all the wonderful contributors for their updates. Thanks to Greenhood + Company for sponsoring some of the 1.5.6 updates, and to Campaign Monitor for supporting the web interface. The source code can be found on GitHub. Copyright by Alex Dunae (dunae.ca, e-mail 'code' at the same domain), 2007-2017. See LICENSE.md for license details. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论