$:.unshift File.dirname(__FILE__) require 'rexml/document' require 'template_runner' module BuildMaster class TemplateException < Exception end class XTemplate def initialize(template_file) @template = REXML::Document.new(template_file) end def process(content, &evaluator) content_xml = REXML::Document.new(content) output_xml = process_xml(content_xml, &evaluator) return output_xml end private def process_xml(content_xml, &evaluator) result_xml = REXML::Document.new TemplateRunner.new(result_xml, @template, content_xml, &evaluator).process return result_xml end end end