Path: | lib/premailer/premailer.rb |
Last Update: | Fri Nov 11 06:10:21 +0000 2016 |
Premailer processes HTML and CSS to improve e-mail deliverability.
Premailer‘s main function is to render all CSS as inline style attributes. It also converts relative links to absolute links and checks the ‘safety’ of CSS properties against a CSS support chart.
## Example of use
```ruby premailer = Premailer.new(‘example.com/myfile.html’, :warn_level => Premailer::Warnings::SAFE)
# Write the HTML output fout = File.open("output.html", "w") fout.puts premailer.to_inline_css fout.close
# Write the plain-text output fout = File.open("ouput.txt", "w") fout.puts premailer.to_plain_text fout.close
# List any CSS warnings puts premailer.warnings.length.to_s + ’ warnings found’ premailer.warnings.each do |w|
puts "#{w[:message]} (#{w[:level]}) may not render properly in #{w[:clients]}"
end
premailer = Premailer.new(html_file, :warn_level => Premailer::Warnings::SAFE) puts premailer.to_inline_css ```