Sha256: 8c27b1a46984fc535eb2602f7caa64a58e5ff130bac75553f89f08c6130d6cb0

Contents?: true

Size: 1.21 KB

Versions: 12

Compression:

Stored size: 1.21 KB

Contents

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

require 'webgen/content_processor'
webgen_require 'erubis'

module Webgen
  class ContentProcessor

    # Processes embedded Ruby statements with the +erubis+ library.
    module Erubis

      class CompatibleEruby < ::Erubis::Eruby #:nodoc:
        include ::Erubis::ErboutEnhancer
        include ::Erubis::PercentLineEnhancer
      end

      class CompatiblePIEruby < ::Erubis::PI::Eruby #:nodoc:
        include ::Erubis::ErboutEnhancer
        include ::Erubis::PercentLineEnhancer
      end

      # Including Erubis because of problem with resolving Erubis::XmlHelper et al
      include ::Erubis
      extend ::Erubis::XmlHelper

      # Process the Ruby statements embedded in the content of +context+.
      def self.call(context)
        options = context.website.config['content_processor.erubis.options']
        erubis = if context.website.config['content_processor.erubis.use_pi']
                   CompatiblePIEruby.new(context.content, options)
                 else
                   CompatibleEruby.new(context.content, options)
                 end
        erubis.filename = context.ref_node.alcn
        context.content = erubis.result(binding)
        context
      end

    end

  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
webgen-1.7.3 lib/webgen/content_processor/erubis.rb
webgen-1.7.2 lib/webgen/content_processor/erubis.rb
webgen-1.7.1 lib/webgen/content_processor/erubis.rb
webgen-1.7.0 lib/webgen/content_processor/erubis.rb
webgen-1.6.0 lib/webgen/content_processor/erubis.rb
webgen-1.5.2 lib/webgen/content_processor/erubis.rb
webgen-1.5.1 lib/webgen/content_processor/erubis.rb
webgen-1.5.0 lib/webgen/content_processor/erubis.rb
webgen-1.4.1 lib/webgen/content_processor/erubis.rb
webgen-1.4.0 lib/webgen/content_processor/erubis.rb
webgen-1.3.0 lib/webgen/content_processor/erubis.rb
webgen-1.2.1 lib/webgen/content_processor/erubis.rb