Sha256: c1b14b2d837bd61675b0c25d41562343aacb729cf825b5aabc9121624710dd9d

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 KB

Contents

module Less  
  module Rails
    class Railtie < ::Rails::Railtie
      
      module LessContext
        attr_accessor :less_config
      end
      
      config.less = ActiveSupport::OrderedOptions.new
      config.less.paths = []
      config.less.compress = false
      config.app_generators.stylesheet_engine :less
      
      config.before_initialize do |app|
        require 'less'
        require 'less-rails'
        Sprockets::Engines #force autoloading
        Sprockets.register_engine '.less', Less::Rails::LessTemplate
      end
      
      initializer 'less-rails.before.load_config_initializers', :before => 'load_config_initializers', :group => :all do |app|
        raise 'The less-rails plugin requires the asset pipeline to be enabled.' unless app.config.assets.enabled
      end
      
      initializer 'less-rails.after.load_config_initializers', :after => 'load_config_initializers', :group => :all do |app|
        app.assets.context_class.extend(LessContext)
        app.assets.context_class.less_config = app.config.less
      end
      
      initializer 'less-rails.setup_compression', :group => :all do |app|
        if app.config.assets.compress
          app.config.assets.css_compressor = CssCompressor.new
        end
      end
      
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
less-rails-2.0.3 lib/less/rails/railtie.rb