Class: ComfyPress::Tag::Asset

Inherits:
Object
  • Object
show all
Includes:
ComfyPress::Tag
Defined in:
lib/comfypress/tags/asset.rb

Constant Summary

Constants included from ComfyPress::Tag

IDENTIFIER_REGEX, TOKENIZER_REGEX

Instance Attribute Summary

Attributes included from ComfyPress::Tag

#identifier, #namespace, #page, #params, #parent

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.regex_tag_signature(identifier = nil) ⇒ Object



4
5
6
7
# File 'lib/comfypress/tags/asset.rb', line 4

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

Instance Method Details

#contentObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/comfypress/tags/asset.rb', line 9

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