Sha256: 7277c1df16b0380b2276e969c25e26a01c0afdb76915251d6f20aa99a87b9800

Contents?: true

Size: 868 Bytes

Versions: 2

Compression:

Stored size: 868 Bytes

Contents

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

module Webgen::ContentProcessor

  # Processes embedded Ruby statements.
  class Erb

    include Deprecated

    # Process the Ruby statements embedded in the content of +context+.
    def call(context)
      require 'erb'
      extend(ERB::Util)

      website = deprecate('website', 'context.website', context.website)
      node = deprecate('node', 'context.node', context.content_node)
      ref_node = deprecate('ref_node', 'context.ref_node', context.ref_node)
      dest_node = deprecate('dest_node', 'context.dest_node', context.dest_node)

      erb = ERB.new(context.content)
      erb.filename = context.ref_node.alcn
      context.content = erb.result(binding)
      context
    rescue Exception => e
      raise RuntimeError, "Erb processing failed in <#{context.ref_node.alcn}>: #{e.message}", e.backtrace
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gettalong-webgen-0.5.9.20090620 lib/webgen/contentprocessor/erb.rb
gettalong-webgen-0.5.9.20090626 lib/webgen/contentprocessor/erb.rb