Skip to content

Commit

Permalink
Merge pull request #177 from sul-dlss/restore_to_html
Browse files Browse the repository at this point in the history
Restore to_html method to nested related item field.
  • Loading branch information
justinlittman authored Dec 11, 2023
2 parents 833e826 + 398a792 commit cbe0768
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/mods_display/fields/nested_related_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@ def fields
end
end

# Used by exhibits
def to_html(view_context = ApplicationController.renderer)
helpers = view_context.respond_to?(:simple_format) ? view_context : ApplicationController.new.view_context

component = ModsDisplay::ListFieldComponent.with_collection(
fields,
value_transformer: ->(value) { helpers.format_mods_html(value.to_s) },
list_html_attributes: { class: 'mods_display_nested_related_items' },
list_item_html_attributes: { class: 'mods_display_nested_related_item open' }
)

view_context.render component, layout: false
end

# this class provides html markup and is subclassed in purl application
class ValueRenderer
def initialize(related_item_element)
Expand Down

0 comments on commit cbe0768

Please sign in to comment.