Class: Serve::SassHandler

Inherits:
FileTypeHandler show all
Defined in:
lib/serve/handlers/sass_handler.rb

Overview

TODO: Figure out how to remove the Sass Handler in favor of Tilt The Sass handler seems to be necessary to keep Tilt from applying a layout to Sass files. Any one know how to turn this Tilt feature off?

Instance Method Summary collapse

Methods inherited from FileTypeHandler

extension, find, handlers, #initialize, #process

Constructor Details

This class inherits a constructor from Serve::FileTypeHandler

Instance Method Details

#content_typeObject



30
31
32
# File 'lib/serve/handlers/sass_handler.rb', line 30

def content_type
  'text/css'
end

#parse(string) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/serve/handlers/sass_handler.rb', line 10

def parse(string)
  require 'sass'
  engine = Sass::Engine.new(string,
    :load_paths => [@root_path],
    :style => :expanded,
    :filename => @script_filename,
    :syntax => syntax(@script_filename)
  )
  engine.render
end

#syntax(filename) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/serve/handlers/sass_handler.rb', line 21

def syntax(filename)
  ext = File.extname(@script_filename)
  if ext == '.scss'
    :scss
  else
    :sass
  end
end