Class: Rack::SassCompiler
- Inherits:
-
AssetCompiler
- Object
- AssetCompiler
- Rack::SassCompiler
- Defined in:
- lib/rack/sass_compiler.rb
Constant Summary
Constants inherited from AssetCompiler
Instance Attribute Summary collapse
-
#sass_options ⇒ Object
Returns the value of attribute sass_options.
Attributes inherited from AssetCompiler
#source_dir, #source_extension, #url
Instance Method Summary collapse
- #compile(source_file) ⇒ Object
- #get_load_paths(src_dir) ⇒ Object
-
#initialize(app, options = {}) ⇒ SassCompiler
constructor
A new instance of SassCompiler.
Methods inherited from AssetCompiler
Constructor Details
#initialize(app, options = {}) ⇒ SassCompiler
Returns a new instance of SassCompiler.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/rack/sass_compiler.rb', line 8 def initialize(app, ={}) = { :url => '/stylesheets', :content_type => 'text/css', }.merge() [:sass_options] ||= {} [:sass_options] = { :syntax => :scss, :cache => false }.merge([:sass_options]) @sass_options = [:sass_options] [:source_extension] ||= @sass_options[:syntax].to_s super end |
Instance Attribute Details
#sass_options ⇒ Object
Returns the value of attribute sass_options.
6 7 8 |
# File 'lib/rack/sass_compiler.rb', line 6 def @sass_options end |
Instance Method Details
#compile(source_file) ⇒ Object
37 38 39 40 41 |
# File 'lib/rack/sass_compiler.rb', line 37 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 |
#get_load_paths(src_dir) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/rack/sass_compiler.rb', line 27 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 |