Sha256: dc7c579c9641b6446dd8d5a1f3b6310ec4b0cfa5793fc96407e2edc5e4217278

Contents?: true

Size: 860 Bytes

Versions: 2

Compression:

Stored size: 860 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'

      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.absolute_lcn
      context.content = erb.result(binding)
      context
    rescue Exception => e
      raise RuntimeError, "Erb processing failed in <#{context.ref_node.absolute_lcn}>: #{e.message}", e.backtrace
    end

  end

end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
gettalong-webgen-0.5.8.20090507 lib/webgen/contentprocessor/erb.rb
webgen-0.5.8 lib/webgen/contentprocessor/erb.rb