Method: WebAssets::StylesheetProcessor#content

Defined in:
lib/web_assets/stylesheet_processor.rb

#content(filename, options) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/web_assets/stylesheet_processor.rb', line 37

def content filename, options
  filepath = full_path filename.sub(RE_EXTENSION, '')
  WebAssets.logger.debug "StylesheetProcessor#content #{filepath.inspect}"
  content = case
  when File.exists?("#{filepath}.css")
    WebAssets.logger.debug "StylesheetProcessor#content: File.read"
    File.read "#{filepath}.css"
  when File.exists?("#{filepath}.scss")
    WebAssets.logger.debug "StylesheetProcessor#content: #render_sass_file/scss"
    render_sass_file filepath, :scss, render_options(options)
  when File.exists?("#{filepath}.sass")
    WebAssets.logger.debug "StylesheetProcessor#content: #render_sass_file/sass"
    render_sass_file filepath, :sass, render_options(options)
  else
    ""
  end
  options[:gzip] ? Gzipper.compress(content) : content
end