Sha256: 93b939de8e7cf28a51146ebd45c0c37b8a104a59d434f81c206bf2e65dedb68e

Contents?: true

Size: 967 Bytes

Versions: 3

Compression:

Stored size: 967 Bytes

Contents

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

  def self.regex_tag_signature(identifier = nil)
    identifier ||= IDENTIFIER_REGEX
    /\{\{\s*cms:asset:(#{identifier}):?(.*?)\s*\}\}/
  end

  def content
    return unless (layout = Comfy::Cms::Layout.find_by_identifier(identifier))
    type    = params[0]
    format  = params[1]

    base = ComfortableMexicanSofa.config.public_cms_path || ''
    unless base.ends_with?("/") # => true
      base = base + "/"
    end

    case type
    when 'css'
      out = "#{base}cms-css/#{blockable.site.id}/#{identifier}/#{layout.cache_buster}.css"
      out = "<link href='#{out}' media='screen' rel='stylesheet' type='text/css' />" if format == 'html_tag'
      out
    when 'js'
      out = "#{base}cms-js/#{blockable.site.id}/#{identifier}/#{layout.cache_buster}.js"
      out = "<script src='#{out}' type='text/javascript'></script>" if format == 'html_tag'
      out
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
comfortable_mexican_sofa-1.12.11 lib/comfortable_mexican_sofa/tags/asset.rb
comfortable_mexican_sofa-1.12.10 lib/comfortable_mexican_sofa/tags/asset.rb
comfortable_mexican_sofa-1.12.9 lib/comfortable_mexican_sofa/tags/asset.rb