github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

sstephenson / sprockets-rails

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 92
    • 20
  • Source
  • Commits
  • Network (20)
  • Issues (2)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

Sprockets JavaScript dependency management and concatenation support for Rails applications — Read more

  cancel

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Load sources from engine-style plugins (those with an app directory) 
Jeffrey Hardy (author)
Sat Nov 28 22:01:35 -0800 2009
commit  1bffeeb51886abe6c6c37cdaee043a6b5787710a
tree    5d70774d12105564de76dc763bfd93f2d971e1bc
parent  6fcb7bfda3818d0e717758895be9a364bf546f1e
sprockets-rails /
name age
history
message
file .gitignore Tue Jan 27 16:58:37 -0800 2009 Initial commit [sstephenson]
file MIT-LICENSE Tue Jan 27 16:58:37 -0800 2009 Initial commit [sstephenson]
file README.markdown Tue Feb 24 10:02:43 -0800 2009 Fix the ordered-list markdown for github [sstephenson]
file Rakefile Tue Jan 27 16:58:37 -0800 2009 Initial commit [sstephenson]
directory config/ Sat Nov 28 22:01:35 -0800 2009 Load sources from engine-style plugins (those w... [Jeffrey Hardy]
file init.rb Tue Jan 27 16:58:37 -0800 2009 Initial commit [sstephenson]
file install.rb Thu Feb 12 12:09:59 -0800 2009 Use File.expand_path when computing RAILS_ROOT ... [sstephenson]
directory lib/ Mon Aug 17 14:10:50 -0700 2009 Set "SprocketsApplication.use_page_caching = fa... [sstephenson]
directory tasks/ Mon Jul 20 11:10:51 -0700 2009 Adjusted rake tasks to include environment via ... [hpoydar]
directory test/ Tue Jan 27 16:58:37 -0800 2009 Initial commit [sstephenson]
README.markdown

sprockets-rails

The sprockets-rails plugin sets up your Rails application for use with Sprockets. To install it, first install the sprockets RubyGem, then check out a copy of the sprockets-rails repository into your vendor/plugins/ directory. When you run the bundled install.rb script, sprockets-rails will create two new directories in your application and copy a configuration file into your config/ directory.

sprockets-rails includes a controller named SprocketsController that renders your application's Sprockets concatenation. When caching is enabled, e.g. in production mode, SprocketsController uses Rails page caching to save the concatenated output to public/sprockets.js the first time it is requested. When caching is disabled, e.g. in development mode, SprocketsController will render a fresh concatenation any time a source file changes.

To source Sprockets' JavaScript concatenation from your HTML templates, use the provided sprockets_include_tag helper.

sprockets-rails also includes a set of Rake tasks for generating the concatenation (rake sprockets:install_script) and installing provided assets (rake sprockets:install_assets). Run sprockets:install_assets any time you add or update a Sprockets plugin in your application. Add sprockets:install_script as a Capistrano post-deploy hook to generate the Sprockets concatenation on your servers automatically at deploy time.

Here's a walkthrough of the installation process:

  1. gem install --remote sprockets

  2. script/plugin install git://github.com/sstephenson/sprockets-rails.git

    You now have app/javascripts/ and vendor/sprockets/ directories in your application, as well as a config/sprockets.yml file.

  3. Edit your config/routes.rb file to add routes for SprocketsController:

    ActionController::Routing::Routes.draw do |map|
      # Add the following line:
      SprocketsApplication.routes(map) 
      ...
    end
    
  4. Move your JavaScript source files from public/javascripts/ into app/javascripts/. All files in all subdirectories of app/javascripts/ will be required by Sprockets in alphabetical order, with the exception of app/javascripts/application.js, which is required before any other file. (You can change this behavior by editing the source_files line of config/sprockets.yml.)

  5. Adjust your HTML templates to call <%= sprockets_include_tag %> instead of <%= javascript_include_tag ... %>.

Once sprockets-rails is installed, you can check out Sprockets plugins into the vendor/sprockets/ directory. By default, sprockets-rails configures Sprockets' load path to search vendor/sprockets/*/src/, as well as vendor/plugins/*/javascripts/. This means that the javascripts/ directories of Rails plugins are automatically installed into your Sprockets load path.

License

Copyright © 2009 Sam Stephenson.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server