# -*- ruby -*- # # Using . See also sample10.rb. # require 'xtemplate' class Link attr_reader :url, :name def initialize(url, name) @url = url @name = name end def href(ty = nil) ty ||= 'http' "#{ty}://#{@url}/" end end data ={ 'links' => [ Link.new("www.foo.my", "anchor1"), Link.new("www.bar.my", "anchor2"), Link.new("ftp.foo.my", "anchor3"), ] } text = < EOF t = XTemplate::XMLTemplate.new(text) print(t.expand(data))