Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Apply CSS styles from a stylesheet directly into element attributes

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.markdown
Octocat-spinner-32 Rakefile
Octocat-spinner-32 VERSION
Octocat-spinner-32 inline_styles.gemspec
README.markdown

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  "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.

Something went wrong with that request. Please try again.