Class: Webgen::ContentProcessor::Erb

Inherits:
Object
  • Object
show all
Includes:
Deprecated
Defined in:
lib/webgen/contentprocessor/erb.rb

Overview

Processes embedded Ruby statements.

Instance Method Summary collapse

Methods included from Deprecated

#deprecate

Instance Method Details

#call(context) ⇒ Object

Process the Ruby statements embedded in the content of context.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/webgen/contentprocessor/erb.rb', line 11

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