Sha256: 03ff3d53a5bf24cdf1ac372ff56c39c30d72b3efc2e440b1b3564e1ff46acf70

Contents?: true

Size: 1.09 KB

Versions: 5

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.readable_content_type
              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

5 entries across 5 versions & 1 rubygems

Version Path
govuk_publishing_components-16.20.1 app/views/govuk_publishing_components/components/_attachment_link.html.erb
govuk_publishing_components-16.20.0 app/views/govuk_publishing_components/components/_attachment_link.html.erb
govuk_publishing_components-16.19.0 app/views/govuk_publishing_components/components/_attachment_link.html.erb
govuk_publishing_components-16.18.0 app/views/govuk_publishing_components/components/_attachment_link.html.erb
govuk_publishing_components-16.17.0 app/views/govuk_publishing_components/components/_attachment_link.html.erb