cascading-resources

This gem adds the ability to automatically includes javascripts and stylesheets based on the controller and action_name.

Usage

In the <head> tag in your layout, include one or both of the following:

= stylesheet_link_tag :cascades
= javascript_link_tag :cascades

Given an example request to controller: items, action: show:

For stylesheet cascading, this will auto include:

  • /public/stylesheets/application.css

  • /public/stylesheets/items.css

  • /public/stylesheets/items/show.css

For javascript cascading, this will auto include:

  • /public/javascripts/application.js

  • /public/javascripts/items.js

  • /public/javascripts/items/show.js

In case you wish to search multiple directories under public/javascripts|stylesheets (as some users of sass may want to), the following options can be set (most likely, you will want to set these in environment.rb):

CascadingResources::STYLESHEETS_DIRECTORIES = ["","compiled"]
CascadingResources::JAVASCRIPTS_DIRECTORIES = ["min"]

The first instruction would look for:

  • /public/stylesheets/application.css

  • /public/stylesheets/items.css

  • /public/stylesheets/items/show.css

  • /public/stylesheets/compiled/application.css

  • /public/stylesheets/compiled/items.css

  • /public/stylesheets/compiled/items/show.css

The second instruction would look for:

  • /public/javascripts/min/application.js

  • /public/javascripts/min/items.js

  • /public/javascripts/min/items/show.js

Tests coming soon!

Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)

  • Send me a pull request. Bonus points for topic branches.

Copyright © 2009 James Stuart. See LICENSE for details.