Class: Awestruct::Handlers::HamlHandler

Inherits:
BaseHandler show all
Defined in:
lib/awestruct/handlers/haml_handler.rb

Instance Attribute Summary

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_path, #path, #raw_content, #relative_source_path, #stale?, #to_chain

Constructor Details

#initialize(site, delegate) ⇒ HamlHandler

Returns a new instance of HamlHandler.



10
11
12
# File 'lib/awestruct/handlers/haml_handler.rb', line 10

def initialize(site, delegate)
  super( site, delegate )
end

Instance Method Details

#output_extensionObject



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

def output_extension
  File.extname( File.basename( path, '.haml' ) )
end

#output_filenameObject



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

def output_filename
  return File.basename( relative_source_path, '.haml' ) unless relative_source_path.nil?
  nil
end

#rendered_content(context, with_layouts = true) ⇒ Object



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

def rendered_content(context, with_layouts=true)
  options = context.site.haml? ? context.site.haml : {}
  options = options.inject({}){ |hash,(key,value)| 
    hash[key.to_sym] = value
    hash
  }
  options[:relative_source_path] = context.page.relative_source_path
  options[:filename] = delegate.path
  options[:line]     = delegate.content_line_offset + 1
  options[:site] = context.site
  haml_engine = Haml::Engine.new( delegate.raw_content, options )
  haml_engine.render( context )
end

#simple_nameObject



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

def simple_name
  File.basename( self.path, "#{output_extension}.haml" )
end