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 Attribute Summary

Attributes inherited from FileTypeHandler

#extension

Instance Method Summary collapse

Methods inherited from FileTypeHandler

configure, extension, extension_options, extensions, handlers, handlers_for, #initialize, #layout?, options_for, #process

Constructor Details

This class inherits a constructor from Serve::FileTypeHandler

Instance Method Details

#content_typeObject



28
29
30
# File 'lib/serve/handlers/sass_handler.rb', line 28

def content_type
  'text/css'
end

#parse(string, context) ⇒ Object



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

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

#syntaxObject



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

def syntax
  if extension == 'scss'
    :scss
  else
    :sass
  end
end