Cascading Stylesheets
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:
- application.css;
- #{RAILS_ENV}.css (ie. development.css, production.css, uat.css, etc.);
- layouts/#{layout_name}.css (eg. layouts/print.css); and
- #{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">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
...
<%= stylesheet_link_tag :defaults %>
<%= javascript_include_tag :defaults %>
</head>
<body>
...
</body>
</html>
See Also
- Cascading Javascripts (cascading_javascripts).
Installation
EDGE
To install using SVN:ruby script/plugin install svn://rubyforge.org/var/svn/redhillonrails/trunk/vendor/plugins/cascading_stylesheets
or using HTTP:
ruby script/plugin install http://redhillonrails.rubyforge.org/svn/trunk/vendor/plugins/cascading_stylesheets
2.0 Stable
To install using SVN:ruby script/plugin install svn://rubyforge.org/var/svn/redhillonrails/branches/stable-2.0/vendor/plugins/cascading_stylesheets
or using HTTP:
ruby script/plugin install http://redhillonrails.rubyforge.org/svn/branches/stable-2.0/vendor/plugins/cascading_stylesheets
1.2 Stable
To install using SVN:ruby script/plugin install svn://rubyforge.org/var/svn/redhillonrails/branches/stable-1.2/vendor/plugins/cascading_stylesheets
or using HTTP:
ruby script/plugin install http://redhillonrails.rubyforge.org/svn/branches/stable-1.2/vendor/plugins/cascading_stylesheets
1.1.6 Release
To install using SVN:ruby script/plugin install svn://rubyforge.org/var/svn/redhillonrails/tags/release-1.1.6/vendor/plugins/cascading_stylesheets
or using HTTP:
ruby script/plugin install http://redhillonrails.rubyforge.org/svn/tags/release-1.1.6/vendor/plugins/cascading_stylesheets
