Sha256: ed4185abcb38e9bb4bce5b80ff6bf30bee6faab1833ed4b6ccc158b40f41b13b

Contents?: true

Size: 973 Bytes

Versions: 6

Compression:

Stored size: 973 Bytes

Contents

require 'awestruct/renderable'

module Awestruct
  class RenderableFile < Renderable

    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

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

    def render(context)
      raw_page_content
    end

    def output_extension
      File.extname( self.source_path )
    end

    def output_filename
      File.basename( self.source_path )
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
awestruct-0.2.18 lib/awestruct/renderable_file.rb
awestruct-0.2.17 lib/awestruct/renderable_file.rb
awestruct-0.2.15 lib/awestruct/renderable_file.rb
awestruct-0.2.14 lib/awestruct/renderable_file.rb
awestruct-0.2.13 lib/awestruct/renderable_file.rb
awestruct-0.2.12 lib/awestruct/renderable_file.rb