lib/buildmaster/xtemplate.rb in BuildMaster-0.7.0 vs lib/buildmaster/xtemplate.rb in BuildMaster-0.8.0
- old
+ new
@@ -2,27 +2,26 @@
require 'rexml/document'
require 'template_runner'
module BuildMaster
- class TemplateException < Exception
- end
-
class XTemplate
- def initialize(template_file)
+ def initialize(template_file, templatelets = Hash.new)
@template = REXML::Document.new(template_file)
+ @templatelets = templatelets
end
- def process(content, &evaluator)
- content_xml = REXML::Document.new(content)
- output_xml = process_xml(content_xml, &evaluator)
+ def process(source, &evaluator)
+ output_xml = process_xml(source, &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
+ def process_xml(source, &evaluator)
+ output_xml = REXML::Document.new
+ runner = TemplateRunner.new(output_xml, @template, source, &evaluator)
+ runner.templatelets = @templatelets
+ runner.process
+ return output_xml
end
end
end