Sha256: 5b27aa3634df6d65b44951d9a9776a2c58664b887a2aed42b4ed0f2defce6b62

Contents?: true

Size: 849 Bytes

Versions: 8

Compression:

Stored size: 849 Bytes

Contents

class Premailer
  module Rails
    class CustomizedPremailer < ::Premailer
      def initialize(html)
        # In order to pass the CSS as string to super it is necessary to access
        # the parsed HTML beforehand. To do so, the adapter needs to be
        # initialized. The ::Premailer::Adaptor handles the discovery of a
        # suitable adaptor (Nokogiri or Hpricot). To make load_html work, an
        # adaptor needs to be included and @options[:with_html_string] needs to
        # be set. For further information, refer to ::Premailer#initialize.
        @options = Rails.config.merge(with_html_string: true)
        Premailer.send(:include, Adapter.find(Adapter.use))
        doc = load_html(html)
        options = @options.merge(css_string: CSSHelper.css_for_doc(doc))

        super(doc.to_s, options)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
premailer-rails-1.9.7 lib/premailer/rails/customized_premailer.rb
premailer-rails-1.9.6 lib/premailer/rails/customized_premailer.rb
premailer-rails-1.9.5 lib/premailer/rails/customized_premailer.rb
premailer-rails-1.9.4 lib/premailer/rails/customized_premailer.rb
premailer-rails-1.9.3 lib/premailer/rails/customized_premailer.rb
premailer-rails-1.9.2 lib/premailer/rails/customized_premailer.rb
premailer-rails-1.9.1 lib/premailer/rails/customized_premailer.rb
premailer-rails-1.9.0 lib/premailer/rails/customized_premailer.rb