Sha256: f5b8fad499f13b14aff906921f45711c4fab3cbe5ad236f70b7eacd399e7776c
Contents?: true
Size: 1.1 KB
Versions: 12
Compression:
Stored size: 1.1 KB
Contents
require 'rack/asset_compiler' require 'sass' module Rack class SassCompiler < AssetCompiler attr_accessor :sass_options def initialize(app, options={}) options options = { :url => '/stylesheets', :content_type => 'text/css', }.merge(options) options[:sass_options] ||= {} options[:sass_options] = { :syntax => :scss, :cache => false }.merge(options[:sass_options]) @sass_options = options[:sass_options] options[:source_extension] ||= @sass_options[:syntax].to_s super end def get_load_paths(src_dir) paths = [src_dir] if defined?(Compass::Frameworks) Compass::Frameworks::ALL.each do |framework| paths << framework.stylesheets_directory if ::File.exists?(framework.stylesheets_directory) end end paths end def compile(source_file) @sass_options[:load_paths] ||= [] @sass_options[:load_paths] = @sass_options[:load_paths] | get_load_paths(source_dir) Sass::Engine.new(::File.read(source_file), @sass_options).render end end end
Version data entries
12 entries across 12 versions & 1 rubygems