Sha256: 61122c2b75b905c00c42aabc476fa950c3de8c7cc18d96ea837aaee79b71390b

Contents?: true

Size: 851 Bytes

Versions: 5

Compression:

Stored size: 851 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(html, options)
      end
    end
  end
end

Version data entries

5 entries across 3 versions & 2 rubygems

Version Path
premailer-rails-1.4.0 lib/premailer/rails/customized_premailer.rb
premailer-rails3-1.3.2 lib/premailer/rails/customized_premailer.rb
premailer-rails3-1.3.2 lib/premailer/rails/premailer.rb
premailer-rails-1.3.2 lib/premailer/rails/customized_premailer.rb
premailer-rails-1.3.2 lib/premailer/rails/premailer.rb