Class: ModsDisplay::Contents
- Defined in:
- lib/mods_display/fields/contents.rb
Instance Method Summary collapse
Methods inherited from Field
Constructor Details
This class inherits a constructor from ModsDisplay::Field
Instance Method Details
#to_html ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/mods_display/fields/contents.rb', line 3 def to_html return nil if fields.empty? || @config.ignore? output = '' fields.each do |field| next unless field.values.any? { |f| f && !f.empty? } output << "<dt#{label_class} #{sanitized_field_title(field.label)}>#{field.label}</dt>" output << "<dd#{value_class}>" output << '<ul><li>' # compress all values into a "--"-delimited string then split them up output << field.values.join('--').split('--').map(&:strip).map do |val| @config.link ? link_to_value(val.to_s) : link_urls_and_email(val.to_s) end.join('</li><li>') output << '</li></ul>' output << '</dd>' end output end |