Class: Geoblacklight::MetadataDescriptionMarkdownComponent

Inherits:
Blacklight::MetadataFieldComponent
  • Object
show all
Defined in:
app/components/geoblacklight/metadata_description_markdown_component.rb

Instance Method Summary collapse

Instance Method Details

#markdown_to_html(value) ⇒ ActiveSupport::SafeBuffer

Transform markdown into HTML

Parameters:

  • value (String)

    markdown to transform

Returns:

  • (ActiveSupport::SafeBuffer)

    rendered HTML



8
9
10
# File 'app/components/geoblacklight/metadata_description_markdown_component.rb', line 8

def markdown_to_html(value)
  Commonmarker.to_html(value).html_safe
end

#render_field_valuesObject



12
13
14
15
16
17
18
19
# File 'app/components/geoblacklight/metadata_description_markdown_component.rb', line 12

def render_field_values
  [tag.div(class: "truncate-abstract", data: {
    read_more_text: t("geoblacklight.truncate.read_more"),
    close_text: t("geoblacklight.truncate.close")
  }) do
    safe_join(Array(@field.values).flatten.map { |value| markdown_to_html(value) })
  end]
end