Sha256: 86c42da0cff346c47208275b814162f5e9a011b0436d1f3da6d20e7bb23e47f0
Contents?: true
Size: 840 Bytes
Versions: 3
Compression:
Stored size: 840 Bytes
Contents
# frozen_string_literal: true module ModsDisplay class Contents < Field def to_html(view_context = ApplicationController.renderer) f = fields.map do |field| ModsDisplay::Values.new(label: field.label, values: [field.values.join("\n\n")]) end helpers = view_context.respond_to?(:simple_format) ? view_context : ApplicationController.new.view_context value_transformer = lambda do |value| text = ERB::Util.h(value.gsub(' ', "\n")) helpers.simple_format(text, {}, sanitize: false) end component = ModsDisplay::FieldComponent.with_collection(f, value_transformer: value_transformer) view_context.render component, layout: false end private def displayLabel(element) super(element) || I18n.t('mods_display.table_of_contents') end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
mods_display-1.1.0 | lib/mods_display/fields/contents.rb |
mods_display-1.0.0 | lib/mods_display/fields/contents.rb |
mods_display-1.0.0.alpha5 | lib/mods_display/fields/contents.rb |