Class: Awestruct::Handlers::BaseSassHandler

Inherits:
BaseHandler
  • Object
show all
Defined in:
lib/awestruct/handlers/base_sass_handler.rb

Direct Known Subclasses

SassHandler, ScssHandler

Instance Attribute Summary collapse

Attributes inherited from BaseHandler

#delegate, #site

Instance Method Summary collapse

Methods inherited from BaseHandler

#content_line_offset, #content_syntax, #front_matter, #inherit_front_matter, #input_mtime, #output_extension, #output_path, #path, #raw_content, #relative_source_path, #stale?, #to_chain

Constructor Details

#initialize(site, delegate, syntax) ⇒ BaseSassHandler

Returns a new instance of BaseSassHandler.



14
15
16
17
# File 'lib/awestruct/handlers/base_sass_handler.rb', line 14

def initialize(site, delegate, syntax)
  super( site, delegate )
  @syntax = syntax
end

Instance Attribute Details

#syntaxObject (readonly)

Returns the value of attribute syntax.



12
13
14
# File 'lib/awestruct/handlers/base_sass_handler.rb', line 12

def syntax
  @syntax
end

Instance Method Details

#output_filenameObject



23
24
25
# File 'lib/awestruct/handlers/base_sass_handler.rb', line 23

def output_filename
  simple_name + '.css'
end

#rendered_content(context, with_layouts = true) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/awestruct/handlers/base_sass_handler.rb', line 27

def rendered_content(context, with_layouts=true)
  sass_opts = Compass.sass_engine_options
  sass_opts[:load_paths] ||= []
  Compass::Frameworks::ALL.each do |framework|
    sass_opts[:load_paths] << framework.stylesheets_directory
  end
  sass_opts[:load_paths] << File.dirname( context.page.source_path )
  sass_opts[:syntax] = syntax
  sass_opts[:custom] = site
  sass_engine = Sass::Engine.new( raw_content, sass_opts )
  sass_engine.render
end

#simple_nameObject



19
20
21
# File 'lib/awestruct/handlers/base_sass_handler.rb', line 19

def simple_name
  File.basename( relative_source_path, ".#{syntax}" )
end