Sha256: 0949636ea368bb59782ec9adc6345c397a41435d19083df8cc35b90f5a5005ef

Contents?: true

Size: 1.09 KB

Versions: 14

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

14 entries across 14 versions & 2 rubygems

Version Path
awestruct-0.4.4 lib/awestruct/handlers/erb_handler.rb
awestruct-0.4.3 lib/awestruct/handlers/erb_handler.rb
awestruct-0.4.2 lib/awestruct/handlers/erb_handler.rb
awestruct-0.4.2.x10 lib/awestruct/handlers/erb_handler.rb
awestruct-0.4.2.x9 lib/awestruct/handlers/erb_handler.rb
awestruct-0.4.2.x8 lib/awestruct/handlers/erb_handler.rb
awestruct-0.4.2.x7 lib/awestruct/handlers/erb_handler.rb
awestruct-0.4.2.x6 lib/awestruct/handlers/erb_handler.rb
awestruct-0.4.2.x5 lib/awestruct/handlers/erb_handler.rb
awestruct-0.4.2.x4 lib/awestruct/handlers/erb_handler.rb
awestruct-0.4.2.x3 lib/awestruct/handlers/erb_handler.rb
awestruct-0.4.2.x2 lib/awestruct/handlers/erb_handler.rb
awestruct-0.4.2.x1 lib/awestruct/handlers/erb_handler.rb
awestructx-0.4.1.x1 lib/awestruct/handlers/erb_handler.rb