Sha256: e6db4ef65eb4a15f680702619eb1682fda444956a43faab5da9ff5785c4b4688

Contents?: true

Size: 790 Bytes

Versions: 82

Compression:

Stored size: 790 Bytes

Contents

# frozen_string_literal: true

module Decidim
  # A Helper to render and link to resources.
  module AttachmentsHelper
    # Renders a the attachments of a model that includes the
    # HasAttachments concern.
    #
    # attached_to - The model to render the attachments from.
    #
    # Returns nothing.
    def attachments_for(attached_to)
      render partial: "attachments", locals: { attached_to: attached_to }
    end

    # Renders the attachment's title.
    # Checks if the attachment's title is translated or not and use
    # the correct render method.
    #
    # attachment - An Attachment object
    #
    # Returns String.
    def attachment_title(attachment)
      attachment.title.is_a?(Hash) ? translated_attribute(attachment.title) : attachment.title
    end
  end
end

Version data entries

82 entries across 82 versions & 2 rubygems

Version Path
decidim-core-0.5.0 app/helpers/decidim/attachments_helper.rb
decidim-0.5.0 decidim-core/app/helpers/decidim/attachments_helper.rb