Sha256: c43df7fe7928b43fa5ba2f59c6caceaabdf672fbeb385d4234180c754178fefc
Contents?: true
Size: 796 Bytes
Versions: 3
Compression:
Stored size: 796 Bytes
Contents
module PagesCore class AttachmentEmbedder include ActionView::Helpers::AssetTagHelper attr_reader :attachments def initialize(attachments) @attachments = Array(attachments) end def to_html embed_attachments(attachments.map { |f| embed_attachment(f) }) end def embed_attachments(embedded_attachments) embedded_attachments.join(", ") end def embed_attachment(attachment) content_tag( :a, attachment.name, class: "file", href: attachment_path(attachment) ) end private def attachment_path(attachment) Rails.application.routes.url_helpers.attachment_path( attachment.digest, attachment, format: attachment.filename_extension ) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
pages_core-3.6.2 | lib/pages_core/attachment_embedder.rb |
pages_core-3.6.1 | lib/pages_core/attachment_embedder.rb |
pages_core-3.6.0 | lib/pages_core/attachment_embedder.rb |