4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/xmlize/hash.rb', line 4
def tokens_for_xmlize(tag, attributes = {})
attr_tokens = []
other_tokens = []
tag ||= 'object'
(self.merge(attributes)).each do |k, v|
if (k == :tag)
tag = v
elsif (k == :innerHTML)
other_tokens.push(['TEXT', v])
elsif (k.to_s[0..0] == '@')
attr_tokens.push(['ATTR', k.to_s[1..-1], v])
else
other_tokens = other_tokens.concat(v.tokens_for_xmlize(k))
end
end
[['START', tag]] + attr_tokens + other_tokens + [['END', tag]]
end
|