Sha256: c4b0d758612fb55ffc8f6e4b5f0592603ba92f946aef31a118c6aecb92cb682c
Contents?: true
Size: 1.54 KB
Versions: 3
Compression:
Stored size: 1.54 KB
Contents
sprockets-plugin ================ Package assets into gems for non-Rails applications. Installation ------------ ``` bash $ gem install sprockets-plugin ``` Usage ----- Sprockets::Plugin is meant to be used within gems, to package assets for reuse. So the first step is to add it as a dependency in your gemspec: ``` ruby Gem::Specification.new do |s| # ... s.add_runtime_dependency "sprockets-plugin" end ``` And then extend Sprockets::Plugin and add the necessary asset paths: ``` ruby require "sprockets-plugin" class MyPlugin < Sprockets::Plugin # Set the root path to use relative paths in `.append_path` root File.expand_path("../..", __FILE__) append_path "lib/assets/images" append_path "lib/assets/javascripts" append_path "lib/assets/stylesheets" end ``` Now any assets in the "lib/assets" directory will be available to applications that require this gem: ``` ruby require "sprockets" require "my_plugin" map "/assets" do environment = Sprockets::Environment.new # The assets from MyPlugin will be automatically appended. environment.append_path "assets/images" environment.append_path "assets/javascripts" environment.append_path "assets/stylesheets" run environment end ``` Advanced Usage -------------- You can package assets for Rails and non-Rails applications in the following way: ``` ruby if defined? Rails require "my_assets/engine" elsif defined? Sprockets::Plugin require "my_assets/plugin" end ``` Copyright --------- Copyright (c) 2011 [Peter Browne](http://petebrowne.com). See LICENSE for details.
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
sprockets-plugin-0.1.2 | README.md |
sprockets-plugin-0.1.1 | README.md |
sprockets-plugin-0.1.0 | README.md |