Module: Erector::Sass

Included in:
HTMLWidget, Widget
Defined in:
lib/erector/sass.rb

Overview

Adds sass support to Erector widgets.

Sass is an *optional dependency* of the Erector gem, so a call to sass inside a widget will fail unless you have already installed the sass gem (e.g. “gem ‘sass’” in your code or Gemfile).

Current support is barebones. Please offer suggestions (or better yet, patches) for whether and how to support, e.g., caching, loading from files, precompilation, etc.

Instance Method Summary collapse

Instance Method Details

#sass(arg, options = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/erector/sass.rb', line 12

def sass(arg, options = {})
  require "sass"
  options = {:cache => false}.merge(options)
  if arg =~ /[\w\.*]\.s?css/i
    options[:filename] = arg
    sass_text = File.read(arg)
  else
    sass_text = arg
  end
  style raw(::Sass.compile(sass_text, options))
end

#scss(arg, options = {}) ⇒ Object



24
25
26
# File 'lib/erector/sass.rb', line 24

def scss(arg, options = {})
  sass arg, {:syntax => :scss}.merge(options)
end