Sha256: e6f23a699678ce84369769780ba5943d3662038bc1c901e488d822e2a6d68179
Contents?: true
Size: 1.49 KB
Versions: 2
Compression:
Stored size: 1.49 KB
Contents
require 'uri' require 'nokogiri' require 'css_parser' module Roadie module ActionMailerExtensions def self.included(base) base.class_eval do alias_method_chain :collect_responses_and_parts_order, :inline_styles alias_method_chain :mail, :inline_styles end end protected def mail_with_inline_styles(headers = {}, &block) @inline_style_css_targets = headers[:css] mail_without_inline_styles(headers.except(:css), &block).tap do |email| email[:css] = nil end end def collect_responses_and_parts_order_with_inline_styles(headers, &block) responses, order = collect_responses_and_parts_order_without_inline_styles(headers, &block) new_responses = [] responses.each do |response| new_responses << inline_style_response(response) end [new_responses, order] end private def inline_style_response(response) if response[:content_type] == 'text/html' response.merge :body => Roadie.inline_css(css_rules, response[:body], Rails.application.config.action_mailer.default_url_options) else response end end def css_targets return nil if @inline_style_css_targets == false Array(@inline_style_css_targets || self.class.default[:css] || []).map { |target| target.to_s } end def css_rules @css_rules ||= Roadie.load_css(Rails.root, css_targets) if css_targets.present? end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
roadie-1.0.0.pre2 | lib/roadie/action_mailer_extensions.rb |
roadie-1.0.0.pre1 | lib/roadie/action_mailer_extensions.rb |