Sha256: 7655b95a6de5b28b80a51f1e3ac517b2044c8ac22529bf8ce19761d671f8c97b

Contents?: true

Size: 736 Bytes

Versions: 2

Compression:

Stored size: 736 Bytes

Contents

# -*- encoding: utf-8 -*-

require 'webgen/content_processor'
require 'erb'

module Webgen
  class ContentProcessor

    # Processes embedded Ruby statements.
    module Erb

      extend ERB::Util

      # Process the Ruby statements embedded in the content of +context+.
      def self.call(context)
        erb = if RUBY_VERSION < '2.6'
                ERB.new(context.content, nil, context.website.config['content_processor.erb.trim_mode'] || '')
              else
                ERB.new(context.content, trim_mode: context.website.config['content_processor.erb.trim_mode'])
              end
        erb.filename = context.ref_node.alcn
        context.content = erb.result(binding)
        context
      end

    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
webgen-1.7.3 lib/webgen/content_processor/erb.rb
webgen-1.7.2 lib/webgen/content_processor/erb.rb