Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/dom.rb

Instance Method Summary collapse

Instance Method Details

#dom(tag = nil, mounted: nil, **attr) ⇒ Object



118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/dom.rb', line 118

def dom tag = nil, mounted: nil, **attr
  error_objs = select{|e| e.kind_of?(String).!}
  unless error_objs.empty?
    raise "All array elements must be a string: #{error_objs.first.inspect}"
  end
  if tag
    _tag = Dom.hyphenize(tag)
    "<%s%s>%s</%s>" % [_tag, Dom.attr(attr), Dom.join(self, tag), _tag]
  else
    Dom.join(self, tag)
  end
  .dom_escaped.mounted_set(*map(&:mounted), mounted)
end

#jsonml(tag, attr = nil) ⇒ Object



131
# File 'lib/dom.rb', line 131

def jsonml tag, attr = nil; [Dom.hyphenize(tag), *([Dom.json_attr(attr)] if attr), *self] end