Sha256: 5494e5e485298d135be7c58d7486acae6aa68ff0938f7d679ee2d9a1ee97a123
Contents?: true
Size: 1.87 KB
Versions: 3
Compression:
Stored size: 1.87 KB
Contents
require 'tilt' require 'sprockets' module Sass::Rails class Resolver attr_accessor :context def initialize(context) @context = context end def resolve(path, content_type = :self) options = {} options[:content_type] = content_type unless content_type.nil? context.resolve(path, options) rescue Sprockets::FileNotFound, Sprockets::ContentTypeMismatch nil end def public_path(path, scope) context.asset_paths.compute_public_path(path, scope) end def process(path) context.environment[path].to_s end end 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, :custom => { :resolver => Resolver.new(scope) } ) 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
sass-rails-3.1.0.rc.5 | lib/sass/rails/template_handlers.rb |
sass-rails-3.1.0.rc.4 | lib/sass/rails/template_handlers.rb |
sass-rails-3.1.0.rc.3 | lib/sass/rails/template_handlers.rb |