Class: Docwatch::Util::HTML
- Inherits:
-
Object
- Object
- Docwatch::Util::HTML
- Defined in:
- lib/docwatch/util/html.rb
Class Method Summary collapse
Class Method Details
.render(data) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/docwatch/util/html.rb', line 4 def self.render(data) case data when Hash rows = data.map do |(k, v)| '<th>%s</th><td>%s</td>' % [HTML.render(k), HTML.render(v)] end.join('</tr><tr>') '<table><tr>%s</tr></table>' % rows when Array rows = data.map do |v| '<li>%s</li>' % HTML.render(v) end.join '<ul>%s</ul>' % rows else CGI.escapeHTML(data.to_s) end end |