Sha256: f7c11f342af23d715f4d4dbc931b2b72a0f49c793812c15aaab90591abf970f1

Contents?: true

Size: 1.14 KB

Versions: 2

Compression:

Stored size: 1.14 KB

Contents

require 'stylus/tilt'
require 'stylus/import_processor'

module Stylus
  ### Stylus Railtie
  #
  # `Railtie` that hooks `stylus` inside a Rails application.
  class Railtie < ::Rails::Railtie

    config.app_generators.stylesheet_engine :stylus

    initializer 'stylus.register', :after => 'sprockets.environment', :group => :all do |app|
      if app.config.assets.enabled
        app.assets.register_engine '.styl', Tilt::StylusTemplate
        app.assets.register_preprocessor 'text/css', Stylus::ImportProcessor
      end
    end

    # Initializer block to inspect the `Sprockets` configuration
    # And reflect it on the `Stylus` module;
    # It also includes the `Rails` asset load path into `Stylus` so any
    # `.styl` file inside it can be imported by the `Stylus` API.
    initializer 'stylus.config', :after => :append_assets_path, :group => :all do |app|
      sprockets = app.config.assets
      paths     = sprockets.paths.select { |dir| dir.to_s.ends_with?('stylesheets') }
      if sprockets.enabled
        Stylus.compress = sprockets.compress
        Stylus.debug    = sprockets.debug
        Stylus.paths.concat paths
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
stylus-0.5.1 lib/stylus/railtie.rb
stylus-0.5.0 lib/stylus/railtie.rb