Sha256: 30aece225e5e338d2577e23b9c065f0be9a6b80fcf26a4c6ee6d9620a52f5baa

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

require 'tilt'
require 'sprockets'

module Sass::Rails
  class SassTemplate < Tilt::SassTemplate
    self.default_mime_type = 'text/css'

    def self.engine_initialized?
      defined?(::Sass::Engine)
    end

    def initialize_engine
      require_template_library 'sass'
    end

    def syntax
      :sass
    end

    def sass_options_from_rails(scope)
      scope.environment.context_class.sass_config
    end

    def sass_options(scope)
      importer = self.importer(scope)
      options = sass_options_from_rails(scope)
      load_paths = (options[:load_paths] || []).dup
      load_paths.unshift(importer)
      options.merge(
        :filename => eval_file,
        :line => line,
        :syntax => syntax,
        :importer => importer,
        :load_paths => load_paths
      )
    end

    def importer(scope)
      Sass::Rails::Importer.new(scope)
    end

    def prepare
    end

    def evaluate(scope, locals, &block)
      Sass::Engine.new(data, sass_options(scope)).render
    end
  end

  class ScssTemplate < SassTemplate
    self.default_mime_type = 'text/css'

    def syntax
      :scss
    end
  end
end

Sprockets::Engines #invoke autoloading
Sprockets.register_engine '.sass', Sass::Rails::SassTemplate
Sprockets.register_engine '.scss', Sass::Rails::ScssTemplate

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sass-rails-3.1.0.rc.2 lib/sass/rails/template_handlers.rb