Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Sinatra plugin for Sprockets integration
branch: master

Simplify configuration class

- Move DEFAULT_OPTIONS into Configuration
- Don't use struct when we end up reimplementing everything it gives us
  anyway
- Use instance_variable_set over send(:foo=)
- Fix Ruby warning
latest commit b7ca29dc9b
Andrew Marshall authored
Failed to load latest commit information.
lib Simplify configuration class
.gitignore Initial commit
Gemfile Initial commit
LICENSE Initial commit
README.md Add thanks to contributors and link to list
Rakefile Initial commit
sinatra-sprockets.gemspec Initial commit

README.md

Sinatra Sprockets

Sinatra extension for Sprockets integration.

Installation

Add this line to your application's Gemfile:

gem 'sinatra-sprockets-ext'

or gem install sinatra-sprockets-ext and then manually require it:

require 'sinatra/sprockets'

Currently requires 1.9 (1.8 is near end-of-life anyway).

Usage

Register the plugin in your app.rb:

register Sinatra::Sprockets

In your config.ru, add a mapping for Sprockets:

map "/#{Sinatra::Sprockets.config.prefix}" do
  run Sinatra::Sprockets.environment
end

Optionally configure as needed. Configuration is similar to Rails's Asset Pipeline. Below is an example configuration with some options showing the default values:

Sinatra::Sprockets.configure do |config|
  config.compile = false         # On-the-fly compilation
  config.compress = false        # Compress assets
  config.digest = false          # Append a digest to URLs
  config.css_compressor = false  # CSS compressor instance
  config.js_compressor = false   # JS compressor instance
end

All options and their defaults are shown in lib/sinatra-sprockets/configuration.rb.

You'll also get helper functions that will be familiar to those who use Rails:

  • javascript_include_tag :asset_name
  • stylesheet_link_tag :asset_name
  • asset_path :asset_name

Credits & License

Copyright © 2012 J. Andrew Marshall. All rights reserved. License is available in the LICENSE file.

Special thanks to those who have contributed!

Something went wrong with that request. Please try again.