Sha256: 2b9b292bc438e4be11d009bca935102b4bca9834dd0e788ab449617ba281ab1a

Contents?: true

Size: 807 Bytes

Versions: 3

Compression:

Stored size: 807 Bytes

Contents

module PremailerRails
  class Premailer < ::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 = PremailerRails.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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
premailer-rails3-1.3.1 lib/premailer-rails3/premailer.rb
premailer-rails3-1.3.0 lib/premailer-rails3/premailer.rb
premailer-rails3-1.2.0 lib/premailer-rails3/premailer.rb