Class: Bunch::SassNode
Class Attribute Summary collapse
Attributes inherited from AbstractNode
#options
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from FileNode
#inspect
#write_to_dir, #write_to_file
Constructor Details
#initialize(fn) ⇒ SassNode
Returns a new instance of SassNode.
3
4
5
6
|
# File 'lib/bunch/sass_node.rb', line 3
def initialize(fn)
SassNode.require_sass
@filename = fn
end
|
Class Attribute Details
.style ⇒ Object
35
36
37
|
# File 'lib/bunch/sass_node.rb', line 35
def style
@style ||= (env = ENV['SASS_STYLE']) ? env.to_sym : :nested
end
|
Class Method Details
.require_sass ⇒ Object
26
27
28
29
30
31
32
33
|
# File 'lib/bunch/sass_node.rb', line 26
def require_sass
unless @required
require 'sass'
@required = true
end
rescue LoadError
raise "'gem install sass' to compile .sass and .scss files."
end
|
Instance Method Details
#content ⇒ Object
8
9
10
11
12
|
# File 'lib/bunch/sass_node.rb', line 8
def content
@content ||= fetch(@filename) { Sass::Engine.for_file(@filename, :style => SassNode.style).render }
rescue => e
raise CompileError.new(e, @filename)
end
|
#name ⇒ Object
14
15
16
|
# File 'lib/bunch/sass_node.rb', line 14
def name
File.basename(@filename).sub(/\.s(c|a)ss$/, '')
end
|
#target_extension ⇒ Object
18
19
20
|
# File 'lib/bunch/sass_node.rb', line 18
def target_extension
'.css'
end
|