# -*- ruby -*
#
# Expanding a template with attributed text.
#

require 'xtemplate'

THIS = XTemplate::TextNode

data = {
  'links' => [
    {'@href' => 'http://www.foo.com/', THIS => 'foo.com'},
    {'@href' => 'http://www.bar.com/', THIS => 'bar.com'},
    {'@href' => 'http://www.foo.org/', THIS => 'foo.org'},
  ],
}

text = <<EOF
<?xml version="1.0" encoding="EUC-JP"?>
<links>
  <a id="links">
  </a>
</links>
EOF

t = XTemplate::XMLTemplate.new(text)
print(t.expand(data))