No commit activity in last 3 years
No release in over 3 years
To make your HTML display properly when stylesheet support isn't available (e.g. Gmail) this lets you attach all your CSS to the 'style' attribute of each element.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

InlineStyles

Squish a CSS stylesheet into any semantic html

Why?

HTML-formatted emails don't render uniformly unless the css is attached to the 'style' attribute of every element. Unless you want to maintain your templates with explicit inline styles you'll need to apply them automatically.

How?

class Mailer < ActionMailer::Base
  def message(email)
    recipients email
    subject "Looks nice, eh?"
    html = render(:file   => "message.html",
                  :layout => "email_layout.html")
    body InlineStyles::Page.new.with_html(html).with_css(stylesheet_content).apply
  end

  protected

    def stylesheet_content
      File.read("#{Rails.root}/public/stylesheets/messages.css")
    end
end

Requirements

InlineStyles uses the css_parser and Hpricot gems

Copyright

Copyright (c) 2009 Jack Danger Canty. See LICENSE for details.