129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
# File 'lib/dom.rb', line 129
def dom *tags, mounted: nil, **attr
tag = tags.pop
a = self
if tags.length > 1
error_objs = a.grep_v(Array)
unless error_objs.empty?
raise "Array not deep enough for tag #{tags[-2].inspect}: #{error_objs.first.inspect}"
end
end
unless tags.empty?
a = a.map{|e| e.dom(*tags)}
end
error_objs = a.grep_v(String)
unless error_objs.empty?
raise "All array elements must be a string: #{error_objs.first.inspect}"
end
s = Dom.join(a, tag)
unless tag.nil?
open, close = Dom.format(tag, attr)
s = "<%s>%s</%s>" % [open, s, close]
end
s.dom_escaped.mounted_set(*a.map(&:mounted), mounted)
end
|