Class: Awestruct::RenderableFile

Inherits:
Renderable
  • Object
show all
Defined in:
lib/awestruct/renderable_file.rb

Direct Known Subclasses

FrontMatterFile, SassFile, ScssFile, VerbatimFile

Instance Attribute Summary

Attributes inherited from Renderable

#site

Instance Method Summary collapse

Constructor Details

#initialize(site, source_path, relative_source_path, options = {}) ⇒ RenderableFile

Returns a new instance of RenderableFile.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/awestruct/renderable_file.rb', line 7

def initialize(site, source_path, relative_source_path, options = {})
  super( site )
  self.source_path          = source_path
  self.relative_source_path = relative_source_path
  self.options              = options
  unless ( relative_source_path.nil? )
    dir_name = File.dirname( relative_source_path )
    if ( dir_name == '.' )
      self.output_path          = output_filename
    else
      self.output_path          = File.join( dir_name, output_filename )
    end
  end
end

Instance Method Details

#output_extensionObject



30
31
32
# File 'lib/awestruct/renderable_file.rb', line 30

def output_extension
  File.extname( self.source_path )
end

#output_filenameObject



34
35
36
# File 'lib/awestruct/renderable_file.rb', line 34

def output_filename
  File.basename( self.source_path )
end

#raw_page_contentObject



22
23
24
# File 'lib/awestruct/renderable_file.rb', line 22

def raw_page_content
  File.read( self.source_path ).tap {|f| f.force_encoding(@site.encoding) if @site.encoding }
end

#render(context) ⇒ Object



26
27
28
# File 'lib/awestruct/renderable_file.rb', line 26

def render(context)
  raw_page_content
end