juicer-rails

Rails helper for Juicer - excellent asset packaging tool.

github.com/cjohansen/juicer

Usage

Create config/assets.yml file

js:
  common:
    - 'public/javascripts/jquery/jquery.js'
    - 'public/javascripts/common.js'
  myapp:
    - 'public/javascripts/application.js'
    - 'public/javascripts/dashboard.js'

css:
  myapp:
    - 'public/stylesheets/application.css'
    - 'public/stylesheets/dialogs.css'

juicer-rails provides 2 helper methods

  • merged_javascripts - includes merged javascript assets

  • merged_stylesheets - includes merged and cache-friendly stylesheet assets

Include merged assets in your layout

<head>
    ...
    <%= merged_javascripts :common %>
    <%= merged_javascripts :myapp %>
    <%= merged_stylesheets :myapp %>
    <%= merged_stylesheets :printer, :media => :print %>

</head>

Please note that assets will be compiled only in production environemnt unless always_compile options is set.

Configuration

Create config/initializers/juicer-rails.rb

JuicerRails.setup do |config|
    # config.always_compile = true

    # add more options here
end

Available options are:

* config_file - path of confiugration file. default: config/assets.yml
* config - configuration in YAML format. default: content of config_file 
* environemnt - current environment name. default: Rails.env
* compile_environments - which environments triggers compiling assets. default: production
* always_compile - always compile assets, no matter the environemnt. default: false
* compiled_assets_directory - subdirectory of public directory where compiled assets are stored. default: assets

Copyright © 2010 Michał Łomnicki. See LICENSE for details.