Using XTemplate::YAMLDocument
YAML
YAML is a serialization format designed for human readability. Expansion data of XTemplate is straightforwardly represented in YAML format. YAML4R is a Ruby library to parse/load YAML documents.
XTemplate::YAMLDocument
XTemplate::YAMLDocument is a wrapper class for YAML document.
require 'xtemplate'
require 'xtemplate/yaml'
data = XTemplate::YAMLDocument.new(<<EOS)
members:
  - member:
      name: name1
      age: age1
  - member:
      name: name2
      age: age2
EOS
tpl = XTemplate::XMLTemplate.new(template_text)
tpl.expand(data)