/padrino-sprockets

the best padrino-sprockets

Primary LanguageRuby

Padrino::Sprockets

Sprockets, also known as "the asset pipeline", is a system for pre-processing, compressing and serving up of javascript, css and image assets. Padrino::Sprockets provides integration with the Padrino web framework.

Installation

Install from RubyGems:

$ gem install padrino-sprockets

Or include it in your project's Gemfile with Bundler:

gem 'my-padrino-sprockets', :require => "padrino/sprockets"

Usage

Place your assets under these paths:

app/assets/javascripts
app/assets/images
app/assets/stylesheets

Register sprockets in your application when development environment:

class Redstore < Padrino::Application
  if Padrino.env == :development
    register Padrino::Sprockets
    sprockets  # :url => 'assets', :root => app.root, :mifiy => true
  end
end

In production environment, use the following code in Rakefile to generate precompiled files:

desc 'precompile .css & .js manifest files'
task :precompile do
  root = File.dirname(__FILE__)
  e = Padrino::Sprockets::App.new(nil, minify: true, output: root + '/public/', root: root + '/app')
  e.precompile(%w{application.css application.js})
end

For more documentation about sprockets, have a look at the Sprockets gem.

Helpers Usage

sprockets

:root =>  'asset root' # default is app.root
:url => 'assets'  # default map url, location, default is 'assets'

Contributors