Premailer zet CSS-stijlen inline in HTML-e-mailsjablonen voor consistente weergave in e-mailclients.
Aangepaste Attribuutextensies
Premailer ondersteunt speciale -premailer--CSS-eigenschappen om HTML-tabelattributen te beheren:
table, th, td {
/* Stel width-attribuut in op tabel- en celtags */
-premailer-width: 600px;
}
table, tr, th, td {
/* Stel height-attribuut in op elementen */
-premailer-height: 50px;
}
table {
/* Stel HTML-attributen in op table-tag */
-premailer-cellpadding: 0;
-premailer-cellspacing: 0;
-premailer-border: 0;
}
CLI-Gebruik
# Verwerk invoer-HTML naar inline-uitvoer
premailer input.html > output.html
# Externe HTML-sjabloon ophalen
premailer https://example.com/newsletter.html > inlined.html
Ruby-API
require 'premailer'
premailer = Premailer.new('email.html', warn_level: Premailer::Warnings::SAFE)
# Uitvoer inline HTML
File.open("output.html", "w") do |file|
file.puts premailer.to_inline_css
end
# Uitvoer platte-tekst alternatief
File.open("output.txt", "w") do |file|
file.puts premailer.to_plain_text
end