Sha256: 159b78a0136ece8ab698f175f26f696e3078b78385690921a487e7094169d7f8
Contents?: true
Size: 1.15 KB
Versions: 3
Compression:
Stored size: 1.15 KB
Contents
require 'premailer' module ActionMailer module InStyle class Premailer < ::Premailer def load_css_from_html! load_css_from_asset_pipeline! super end # Uses sprockets and the Rails ~>3.1 asset pipeline # to load the compiled CSS from stylesheet links within the header of the # email temoplate. def load_css_from_asset_pipeline! if tags = @doc.search("link[@rel='stylesheet'], style") tags.each do |tag| if tag.to_s.strip =~ /^\<link/i && tag.attributes['href'] && media_type_ok?(tag.attributes['media']) # If the stylesheet link begins with /assets we must be using the asset pipeline # to generate the css. In this case we should be able to retrieve the css directly # from sprockets if tag.attributes['href'].to_s =~ /\/assets\// link_uri = tag.attributes['href'].to_s asset = Rails.application.assets.find_asset(link_uri.sub(/\/assets\//, '')) @css_parser.add_block!(asset.body) if asset end end end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems