Class: Rack::SassCompiler

Inherits:
AssetCompiler show all
Defined in:
lib/rack/sass_compiler.rb

Constant Summary

Constants inherited from AssetCompiler

AssetCompiler::F

Instance Attribute Summary collapse

Attributes inherited from AssetCompiler

#source_dir, #source_extension, #url

Instance Method Summary collapse

Methods inherited from AssetCompiler

#call, #response

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
# File 'lib/rack/sass_compiler.rb', line 8

def initialize(app, options={})
  options

  options = {
    :url => '/stylesheets',
    :content_type => 'text/css',
    :syntax => :scss
  }.merge(options)

  @syntax = options[:syntax]
  options[:source_extension] ||= syntax.to_s
  super
end

Instance Attribute Details

#syntaxObject

Returns the value of attribute syntax.



6
7
8
# File 'lib/rack/sass_compiler.rb', line 6

def syntax
  @syntax
end

Instance Method Details

#compile(source_file) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/rack/sass_compiler.rb', line 22

def compile(source_file)
  sass_options = {
    :syntax => syntax,
    :cache => false,
    :load_paths => [source_dir]
  }
  Sass::Engine.new(::File.read(source_file), sass_options).render
end