Sha256: ec04a349c3d1432cbe9a7572f3f7401f48a368d866e1a357ded879bc052e1b4d

Contents?: true

Size: 1.09 KB

Versions: 4

Compression:

Stored size: 1.09 KB

Contents

require 'awestruct/handlers/base_handler'
require 'awestruct/handlers/file_handler'
require 'awestruct/handlers/front_matter_handler'
require 'awestruct/handlers/layout_handler'

module Awestruct
  module Handlers
    class ErbHandler < BaseHandler

      CHAIN = Awestruct::HandlerChain.new( /\.erb$/,
        Awestruct::Handlers::FileHandler,
        Awestruct::Handlers::FrontMatterHandler,
        Awestruct::Handlers::ErbHandler,
        Awestruct::Handlers::LayoutHandler
      )

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

      def simple_name
        File.basename( File.basename( relative_source_path, '.erb' ), output_extension )
      end

      def output_filename
        File.basename( relative_source_path, '.erb' )
      end

      def output_extension
        File.extname( output_filename )
      end

      def content_syntax
        :erb
      end

      def rendered_content(context, with_layouts=true)
        erb = ERB.new( delegate.rendered_content( context, with_layouts) )
        erb.result( context.send( :binding ) )
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
awestruct-0.4.8 lib/awestruct/handlers/erb_handler.rb
awestruct-0.4.7 lib/awestruct/handlers/erb_handler.rb
awestruct-0.4.6 lib/awestruct/handlers/erb_handler.rb
awestruct-0.4.5 lib/awestruct/handlers/erb_handler.rb