Sha256: fbc0e04e44de7cc9c1c96ef51d0a28238ba9b82f207278794dbb63f150ebf001
Contents?: true
Size: 728 Bytes
Versions: 14
Compression:
Stored size: 728 Bytes
Contents
# frozen_string_literal: true module ModsDisplay class FieldComponent < ViewComponent::Base with_collection_parameter :field def initialize(field:, delimiter: nil, label_html_attributes: {}, value_html_attributes: {}, value_transformer: nil) super @field = field @delimiter = delimiter @value_transformer = value_transformer @label_html_attributes = label_html_attributes @value_html_attributes = value_html_attributes end def render? @field.values.any?(&:present?) end def format_value(value) if @value_transformer @value_transformer.call(value) else helpers.format_mods_html(value, field: @field) end end end end
Version data entries
14 entries across 14 versions & 1 rubygems