Sha256: a148e588cfa5a185d421cffb74e4d0f0da1f84c097b709e783a938dbc3d6ba19

Contents?: true

Size: 1.26 KB

Versions: 129

Compression:

Stored size: 1.26 KB

Contents

<%
  add_gem_component_stylesheet("attachment-link")

  attachment = GovukPublishingComponents::Presenters::AttachmentHelper.new(attachment)
  target ||= nil
  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
%>
<%= tag.span(class: "gem-c-attachment-link") do %>
  <%= link_to(attachment.title, attachment.url,
              class: "govuk-link",
              target: target,
              data: data_attributes) -%>
  <%= raw("(#{attributes.join(', ')})") if attributes.any? -%>
<% end %>

Version data entries

129 entries across 129 versions & 1 rubygems

Version Path
govuk_publishing_components-45.7.0 app/views/govuk_publishing_components/components/_attachment_link.html.erb
govuk_publishing_components-45.6.1 app/views/govuk_publishing_components/components/_attachment_link.html.erb
govuk_publishing_components-45.6.0 app/views/govuk_publishing_components/components/_attachment_link.html.erb
govuk_publishing_components-45.5.0 app/views/govuk_publishing_components/components/_attachment_link.html.erb
govuk_publishing_components-45.4.1 app/views/govuk_publishing_components/components/_attachment_link.html.erb
govuk_publishing_components-45.4.0 app/views/govuk_publishing_components/components/_attachment_link.html.erb
govuk_publishing_components-45.3.0 app/views/govuk_publishing_components/components/_attachment_link.html.erb
govuk_publishing_components-45.2.0 app/views/govuk_publishing_components/components/_attachment_link.html.erb
govuk_publishing_components-45.1.0 app/views/govuk_publishing_components/components/_attachment_link.html.erb
govuk_publishing_components-45.0.0 app/views/govuk_publishing_components/components/_attachment_link.html.erb
govuk_publishing_components-44.11.0 app/views/govuk_publishing_components/components/_attachment_link.html.erb
govuk_publishing_components-44.10.0 app/views/govuk_publishing_components/components/_attachment_link.html.erb
govuk_publishing_components-44.9.1 app/views/govuk_publishing_components/components/_attachment_link.html.erb
govuk_publishing_components-44.9.0 app/views/govuk_publishing_components/components/_attachment_link.html.erb
govuk_publishing_components-44.8.0 app/views/govuk_publishing_components/components/_attachment_link.html.erb
govuk_publishing_components-44.7.1 app/views/govuk_publishing_components/components/_attachment_link.html.erb
govuk_publishing_components-44.7.0 app/views/govuk_publishing_components/components/_attachment_link.html.erb
govuk_publishing_components-44.6.0 app/views/govuk_publishing_components/components/_attachment_link.html.erb
govuk_publishing_components-44.5.0 app/views/govuk_publishing_components/components/_attachment_link.html.erb
govuk_publishing_components-44.4.2 app/views/govuk_publishing_components/components/_attachment_link.html.erb