Class: Webgen::ContentProcessor::Erubis
- Inherits:
-
Object
- Object
- Webgen::ContentProcessor::Erubis
- Includes:
- WebsiteAccess
- Defined in:
- lib/webgen/contentprocessor/erubis.rb
Overview
Processes embedded Ruby statements with the erubis library.
Instance Method Summary collapse
-
#call(context) ⇒ Object
Process the Ruby statements embedded in the content of
context.
Methods included from WebsiteAccess
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 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/webgen/contentprocessor/erubis.rb', line 11 def call(context) require 'erubis' # including Erubis because of problem with resolving Erubis::XmlHelper et al self.class.class_eval "include ::Erubis" node = context.content_node ref_node = context.ref_node dest_node = context.dest_node = website.config['contentprocessor.erubis.options'] if context[:block] use_pi = context[:block].['erubis_use_pi'] context[:block]..select {|k,v| k =~ /^erubis_/}. each {|k,v| [k.sub(/^erubis_/, '').to_sym] = v } end erubis = if (!use_pi.nil? && use_pi) || (use_pi.nil? && website.config['contentprocessor.erubis.use_pi']) ::Erubis::PI::Eruby.new(context.content, ) else ::Erubis::Eruby.new(context.content, ) end erubis.filename = context.ref_node.absolute_lcn context.content = erubis.result(binding) context rescue Exception => e raise RuntimeError, "Erubis processing failed in <#{context.ref_node.absolute_lcn}>: #{e.}", e.backtrace end |