# File lib/amrita/amx.rb, line 49def Template::[](f)
path = case f
when String
f
when REXML::Document
f.template_href
else
raise "unknown param #{f.type}"
end
doc = REXML::Document.new(REXML::File.new(path))
root = doc.elements['amx']
req = root.attributes['require']
require(req) if req
clsname = root.attributes['class']
cls = if clsname
eval clsname
else
Template
end
cls.new(path, doc)
end
# File lib/amrita/amx.rb, line 117def befor_expand
end
setup_template()
# File lib/amrita/amx.rb, line 120def setup_template
@template = rexml2amrita(@template_root.elements['amx/template'].elements)
end
rexml2amrita(xml)
# File lib/amrita/amx.rb, line 124def rexml2amrita(xml)
case xml
when REXML::Element
h = {}
xml.attributes.each do |k,v|
h[k] = convert(v)
end
e(xml.name, h) {
xml.collect do |x|
rexml2amrita(x)
end
}
when REXML::Elements
ret = xml.collect do |x|
rexml2amrita(x)
end
Node::to_node(ret)
when REXML::Text
TextElement.new convert(xml.to_s)
when REXML::Instruction
"REXML::Instruction here(PENDING)"else
raise "can't convert #{xml.type}"
endend