Sha256: 5bed210debc4f1ad8bd0071f46415e5016491b6cac85ce0a9f2bb3c1ae7b4ad9
Contents?: true
Size: 915 Bytes
Versions: 36
Compression:
Stored size: 915 Bytes
Contents
# frozen_string_literal: true class Premailer module Adapter # Decidim adapter for Premailer module Decidim include ::Premailer::Adapter::Nokogiri # 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. # # @return [String] a plain text. 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 end end end
Version data entries
36 entries across 36 versions & 1 rubygems