Module: ComfortableMexicanSofa::Tag::InstanceMethods

Defined in:
lib/comfortable_mexican_sofa/tag.rb

Instance Method Summary collapse

Instance Method Details

#ancestorsObject

Ancestors of this tag constructed during rendering process.



63
64
65
66
67
# File 'lib/comfortable_mexican_sofa/tag.rb', line 63

def ancestors
  node, nodes = self, []
  nodes << node = node.parent while node.parent
  nodes
end

#blockObject

Find or initialize Comfy::Cms::Block object



89
90
91
92
# File 'lib/comfortable_mexican_sofa/tag.rb', line 89

def block
  blockable.blocks.detect{|b| b.identifier == self.identifier.to_s} || 
  blockable.blocks.build(:identifier => self.identifier.to_s)
end

#contentObject

Content that is accociated with Tag instance.



77
78
79
# File 'lib/comfortable_mexican_sofa/tag.rb', line 77

def content
  nil
end

#idObject

String indentifier of the tag



58
59
60
# File 'lib/comfortable_mexican_sofa/tag.rb', line 58

def id
  "#{self.class.to_s.demodulize.underscore}_#{self.identifier}"
end

#is_cms_block?Boolean

Checks if this tag is using Comfy::Cms::Block

Returns:

  • (Boolean)


95
96
97
# File 'lib/comfortable_mexican_sofa/tag.rb', line 95

def is_cms_block?
  %w(page field collection).member?(self.class.to_s.demodulize.underscore.split(/_/).first)
end

#record_idObject

Used in displaying form elements for Comfy::Cms::Block



100
101
102
# File 'lib/comfortable_mexican_sofa/tag.rb', line 100

def record_id
  block.id
end

#regex_tag_signatureObject

Regex that is used to identify instance of the tag Example:

/<\{\s*?cms:page:tag_identifier\}/


72
73
74
# File 'lib/comfortable_mexican_sofa/tag.rb', line 72

def regex_tag_signature
  self.class.regex_tag_signature(identifier)
end

#renderObject

Content that is used during page rendering. Outputting existing content as a default.



83
84
85
86
# File 'lib/comfortable_mexican_sofa/tag.rb', line 83

def render
  ignore = [ComfortableMexicanSofa::Tag::Partial, ComfortableMexicanSofa::Tag::Helper].member?(self.class)
  ComfortableMexicanSofa::Tag.sanitize_irb(content, ignore)
end