Module: Premailer::Adapter::Decidim
- Includes:
- Nokogiri
- Defined in:
- lib/premailer/adapter/decidim.rb
Overview
Decidim adapter for Premailer
Instance Method Summary collapse
-
#to_plain_text ⇒ String
Converts the HTML document to a format suitable for plain-text e-mail.
Instance Method Details
#to_plain_text ⇒ String
Converts the HTML document to a format suitable for plain-text e-mail.
If present, uses the <body> element as its base; otherwise uses the whole document.
Customized for Decidim in order to strip the inline <style> tags away from the plain text body.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/premailer/adapter/decidim.rb', line 17 def to_plain_text html_src = begin @doc.at("body").inner_html rescue StandardError "" end html_src = @doc.to_html unless html_src && html_src.present? # remove style tags and content html_src.gsub!(%r{<style.*?/style>}m, "") convert_to_text(html_src, @options[:line_length], @html_encoding) end |