Sha256: c46c89b5758619ef99b7150d421fb29dff9023d9120073df671df491374f31e7

Contents?: true

Size: 837 Bytes

Versions: 2

Compression:

Stored size: 837 Bytes

Contents

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

module Webgen::ContentProcessor

  # Processes content that is valid Ruby to build an XML tree. This is done by using the +builder+
  # library.
  class Builder

    # Process the content of +context+ which needs to be valid Ruby code. The special variable +xml+
    # should be used to construct the XML content.
    def call(context)
      require 'builder'

      node = context.content_node
      ref_node = context.ref_node
      dest_node = context.dest_node

      xml = ::Builder::XmlMarkup.new(:indent => 2)
      eval(context.content, binding, context.ref_node.absolute_lcn)
      context.content = xml.target!
      context
    rescue Exception => e
      raise RuntimeError, "Error using Builder in <#{context.ref_node.absolute_lcn}> to generate XML: #{e.message}", e.backtrace
    end

  end

end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
gettalong-webgen-0.5.7.20090227 lib/webgen/contentprocessor/builder.rb
webgen-0.5.7 lib/webgen/contentprocessor/builder.rb