Class: ComfortableMexicanSofa::Tag::Asset

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

Constant Summary

Constants included from ComfortableMexicanSofa::Tag

TOKENIZER_REGEX

Instance Attribute Summary

Attributes included from ComfortableMexicanSofa::Tag

#label, #page, #params, #parent

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.regex_tag_signature(label = nil) ⇒ Object



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

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

Instance Method Details

#contentObject



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

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