Sha256: e529523a4dfa668c11d759eb55037888b1540e44b96e0e5587bb03d4412c50a7

Contents?: true

Size: 1.42 KB

Versions: 6

Compression:

Stored size: 1.42 KB

Contents

<%
  add_gem_component_stylesheet("attachment-link")

  attachment = GovukPublishingComponents::Presenters::AttachmentHelper.new(attachment)
  target ||= nil
  url_data_attributes ||= {}
  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(
      I18n.t("components.attachment.page", count: attachment.number_of_pages),
      class: "gem-c-attachment-link__attribute",
    )
  end

  component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
  component_helper.add_class("gem-c-attachment-link")
%>
<%= tag.span(**component_helper.all_attributes) do %>
  <%= link_to(attachment.title, attachment.url,
              class: "govuk-link",
              target: target,
              data: url_data_attributes) -%>
  <%= raw("(#{attributes.join(', ')})") if attributes.any? -%>
<% end %>

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
govuk_publishing_components-51.1.0 app/views/govuk_publishing_components/components/_attachment_link.html.erb
govuk_publishing_components-51.0.0 app/views/govuk_publishing_components/components/_attachment_link.html.erb
govuk_publishing_components-50.0.1 app/views/govuk_publishing_components/components/_attachment_link.html.erb
govuk_publishing_components-50.0.0 app/views/govuk_publishing_components/components/_attachment_link.html.erb
govuk_publishing_components-49.1.0 app/views/govuk_publishing_components/components/_attachment_link.html.erb
govuk_publishing_components-49.0.0 app/views/govuk_publishing_components/components/_attachment_link.html.erb