README.md in sprockets-helpers-0.3.0 vs README.md in sprockets-helpers-0.4.0

- old
+ new

@@ -25,24 +25,24 @@ ----- Let's build a simple Sinatra app using Sprockets and Sprockets::Helpers (See my fork of [sinatra-asset-pipeline](https://github.com/petebrowne/sinatra-asset-pipeline) for complete setup): ``` ruby -require "sinatra/base" -require "sprockets" -require "sprockets-helpers" +require 'sinatra/base' +require 'sprockets' +require 'sprockets-helpers' class App < Sinatra::Base set :sprockets, Sprockets::Environment.new(root) - set :assets_prefix, "/assets" + set :assets_prefix, '/assets' set :digest_assets, false configure do # Setup Sprockets - sprockets.append_path File.join(root, "assets", "stylesheets") - sprockets.append_path File.join(root, "assets", "javascripts") - sprockets.append_path File.join(root, "assets", "images") + sprockets.append_path File.join(root, 'assets', 'stylesheets') + sprockets.append_path File.join(root, 'assets', 'javascripts') + sprockets.append_path File.join(root, 'assets', 'images') # Configure Sprockets::Helpers (if necessary) Sprockets::Helpers.configure do |config| config.environment = sprockets config.prefix = assets_prefix @@ -59,11 +59,11 @@ # def assets_environment # settings.sprockets # end end - get "/" do + get '/' do erb :index end end ``` @@ -72,17 +72,17 @@ --------------- Simply requiring sprockets-helpers will add the asset path helpers to the Sprocket context, making them available within any asset. For example, a file `assets/javascripts/paths.js.erb`: ``` js+erb -var Paths = { railsImage: "<%= image_path "rails.png" %>" }; +var Paths = { railsImage: "<%= image_path 'rails.png' %>" }; ``` Would be transformed into: ``` javascript -var Paths = { railsImage: "/assets/rails.png" }; +var Paths = { railsImage: '/assets/rails.png' }; ``` Usage in the App ---------------- @@ -95,15 +95,15 @@ <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Sinatra with Sprockets 2 (Asset Pipeline)</title> - <link rel="stylesheet" href="<%= stylesheet_path "application" %>"> - <script src="<%= javascript_path "application" %>"></script> + <link rel="stylesheet" href="<%= stylesheet_path 'application' %>"> + <script src="<%= javascript_path 'application' %>"></script> </head> <body> - <img src="<%= image_path "rails.png" %>"> + <img src="<%= image_path 'rails.png' %>"> </body> </html> ``` Would become: @@ -130,16 +130,34 @@ If the source is not an asset in the Sprockets environment, Sprockets::Helpers will fallback to looking for the file in the application's public directory. It will also append the cache busting timestamp of the file. For example: Given an image, `public/images/logo.jpg`: ``` html+erb -<img src="<%= image_path "logo.jpg" %>"> +<img src="<%= image_path 'logo.jpg' %>"> ``` Would become: ``` html -<img src="/images/logo.jpg?1320093919"> +<img src='/images/logo.jpg?1320093919'> +``` + + +Manifest Usage +-------------- + +**New in 0.4**: Sprockets::Helpers will use the latest fingerprinted filename directly from a `manifest.json` file: + + +``` ruby +# ... +Sprockets::Helpers.configure do |config| + config.environment = sprockets + config.manifest = Sprockets::Manifest.new(sprockets, 'path/to/manifset.json') + config.prefix = assets_prefix + config.public_path = public_folder +end +# ... ``` Copyright ---------