Sha256: 25ad29e07317cfa02fe25c4d3d411cf4f8cbea57afd78a20cd7e1c34969694bb

Contents?: true

Size: 534 Bytes

Versions: 11

Compression:

Stored size: 534 Bytes

Contents

class ComfortableMexicanSofa::Tag::Upload
  include ComfortableMexicanSofa::Tag
  
  def self.regex_tag_signature(label = nil)
    label ||= /[\w\-\.]+/
    /\{\{\s*cms:upload:(#{label}):?(.*?)\s*\}\}/
  end
  
  def content
    return unless upload
    
    format  = params[0]
    text    = params[1] || label
    
    case format
    when 'link'
      "<a href='#{upload.file.url}' target='_blank'>#{text}</a>"
    when 'image'
      "<img src='#{upload.file.url}' alt='#{text}' />"
    else
      upload.file.url
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
comfortable_mexican_sofa-1.3.8 lib/comfortable_mexican_sofa/tags/upload.rb
comfortable_mexican_sofa-1.3.7 lib/comfortable_mexican_sofa/tags/upload.rb
comfortable_mexican_sofa-1.3.6 lib/comfortable_mexican_sofa/tags/upload.rb
comfortable_mexican_sofa-1.3.5 lib/comfortable_mexican_sofa/tags/upload.rb
comfortable_mexican_sofa-1.3.4 lib/comfortable_mexican_sofa/tags/upload.rb
comfortable_mexican_sofa-1.3.3 lib/comfortable_mexican_sofa/tags/upload.rb
comfortable_mexican_sofa-1.3.2 lib/comfortable_mexican_sofa/tags/upload.rb
comfortable_mexican_sofa-1.3.1 lib/comfortable_mexican_sofa/tags/upload.rb
comfortable_mexican_sofa-1.3.0 lib/comfortable_mexican_sofa/tags/upload.rb
comfortable_mexican_sofa-1.2.8 lib/comfortable_mexican_sofa/tags/upload.rb
comfortable_mexican_sofa-1.2.7 lib/comfortable_mexican_sofa/tags/upload.rb