Sha256: bc5b45307eb91059a2be8e0c9494342c2a43f32f58fae0e77a63b81cd4224ebb

Contents?: true

Size: 632 Bytes

Versions: 5

Compression:

Stored size: 632 Bytes

Contents

require 'awestruct/handlers/base_handler'

module Awestruct
  module Handlers
    class InterpolationHandler < BaseHandler

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

      def rendered_content(context, with_layouts=true)
        content = delegate.raw_content

        return nil if content.nil?
        return content unless site.interpolate

        content = content.gsub( /\\/, '\\\\\\\\' )
        content = content.gsub( /\\\\#/, '\\#' )
        content = content.gsub( '@', '\@' )
        content = "%@#{content}@"

        context.instance_eval( content )
      end

    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
awestruct-0.4.2.x2 lib/awestruct/handlers/interpolation_handler.rb
awestruct-0.4.2.x1 lib/awestruct/handlers/interpolation_handler.rb
awestructx-0.4.1.x1 lib/awestruct/handlers/interpolation_handler.rb
awestructx-0.4.1 lib/awestruct/handlers/interpolation_handler.rb
awestructx-0.4.0 lib/awestruct/handlers/interpolation_handler.rb