Plugins - Cascading Stylesheets

StarAdd to favorites

Cascading Stylesheets is a plugin that enhances the behaviour of the built-in stylesheet_link_tag macro to support a :defaults parameter. If :defaults is passed as a parameter, the stylesheet_link_tag macro will load the following stylesheets (if present) in order:

  1. application.css;
  2. #{RAILS_ENV}.css (ie development.css, production.css, uat.css, etc.); and
  3. #{controller_name/action_name}.css (eg. home/index.css, customers/new.css, etc.).

This allows you to define application-wide, environment-specific (such as different backgrounds for UAT and production) and page-specific styles without needing to manually link each one.

To use, simply call stylesheet_link_tag from application.rhtml (in much the same way as you would use javascript_include_tag) passing :defaults as a (or the only) parameter:

  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>

      ...
      <%= stylesheet_link_tag :defaults %>
      <%= javascript_include_tag :defaults %>

      ...

See Also

  • Cascading Javascripts (cascading_javascripts).

Red Hill Consulting

http://www.redhillconsulting.com.au/rails_plugins.html

svn://rubyforge.org/var/svn/redhillonrails/trunk/vendor/plugins/cascading_stylesheets

Rails' (MIT)

  • Currently 2.7/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

View Extensions

Tags

Comments

Add a comment
sscemilxx 2 Jun 2008

about css parameters http://css-lessons.ucoz.com/css-parameters.htm

Search Plugins

Query syntax

Plugins by Category

Sponsors

Rails Kits: Get Code. Get Moving.

Have a comment?