Sha256: a1f85e1df9faf359adefb1b8621873b3bf32492b844438e8901c600ffc76cc92

Contents?: true

Size: 751 Bytes

Versions: 24

Compression:

Stored size: 751 Bytes

Contents

class ComfortableMexicanSofa::Tag::Asset
  include ComfortableMexicanSofa::Tag

  def self.regex_tag_signature(identifier = nil)
    identifier ||= /[\w\-]+/
    /\{\{\s*cms:asset:(#{identifier}):?(.*?)\s*\}\}/
  end

  def content
    return unless (layout = Cms::Layout.find_by_identifier(identifier))
    type    = params[0]
    format  = params[1]
    
    case type
    when 'css'
      out = "/cms-css/#{page.site.id}/#{identifier}.css"
      out = "<link href='#{out}' media='screen' rel='stylesheet' type='text/css' />" if format == 'html_tag'
      out
    when 'js'
      out = "/cms-js/#{page.site.id}/#{identifier}.js"
      out = "<script src='#{out}' type='text/javascript'></script>" if format == 'html_tag'
      out
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
comfortable_mexican_sofa-1.6.3 lib/comfortable_mexican_sofa/tags/asset.rb
comfortable_mexican_sofa-1.6.2 lib/comfortable_mexican_sofa/tags/asset.rb
comfortable_mexican_sofa-1.6.1 lib/comfortable_mexican_sofa/tags/asset.rb
comfortable_mexican_sofa-1.6.0 lib/comfortable_mexican_sofa/tags/asset.rb