public
Description:
Homepage:
Clone URL: git://github.com/stonean/rack-static_assets.git
name age message
file README.md Loading commit data...
README.md

Rack::StaticAssets

The intent is to better define the static resources a page requires and eliminate unnecessary javascript/css inclusions with a centralized declaration and an abstracted implementation (via Rack middleware).

Declarations

The resources a page requires are defined in a central file called static_assets.rb. The directory this file resides in is determined by:

Rack::StaticAssets.config_directory = './config' # default

You can define a grouping of files as:

script_bundle(:jquery).with('jquery.js', 'jquery-ui.js')

style_bundle(:base_style).with('reset.css', 'site.css')

You can build on a bundle:

# Use the :jquery definition above and add 'carousel.js'
script_bundle(:detail).with(:jquery, 'carousel.js')

Apply a bundle to a page:

# Everything under blog gets one script tag and one stylesheet link tag
# which is a combination of the above files
map(:jquery, :base_style).to('/blog/*')


# Chain the same bundle to multiple paths
map(:jquery, :base_style).to('/blog/*').and('/posts/*')

# Apply a bundle to all paths
map(:base_style).to(:all)

Disclaimer

This is just an idea right now...but I think it sounds good. Once I get to the implementation details some/all of the above may change.