Sha256: 1ea6d745dbef8d18fb3969402c4fc356141e96247de48216f1ad25f206093d20

Contents?: true

Size: 1.09 KB

Versions: 2

Compression:

Stored size: 1.09 KB

Contents

<%
  attachment = GovukPublishingComponents::Presenters::Attachment.new(attachment)
  target ||= nil
  attributes = []
  if attachment.content_type_name
    content = if attachment.content_type_abbr
                raw tag.abbr(attachment.content_type.abbr,
                             title: attachment.content_type_name,
                             class: "gem-c-attachment-link__abbr")
              else
                attachment.content_type_name
              end

    attributes << tag.span(content, class: "gem-c-attachment-link__attribute")
  end

  if attachment.file_size
    attributes << tag.span(
      number_to_human_size(attachment.file_size),
      class: "gem-c-attachment-link__attribute",
    )
  end

  if attachment.number_of_pages
    attributes << tag.span(
      pluralize(attachment.number_of_pages, "page"),
      class: "gem-c-attachment-link__attribute",
    )
  end
%>
<%= tag.span(class: "gem-c-attachment-link") do %>
  <%= link_to(attachment.title, attachment.url, class: "govuk-link", target: target) %>
  <%= raw("(#{attributes.join(', ')})") if attributes.any? %>
<% end %>

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
govuk_publishing_components-16.22.0 app/views/govuk_publishing_components/components/_attachment_link.html.erb
govuk_publishing_components-16.21.0 app/views/govuk_publishing_components/components/_attachment_link.html.erb