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.



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

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

#blockObject

Find or initialize Cms::Block object



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

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

#contentObject

Content that is accociated with Tag instance.



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

def content
  nil
end

#idObject

String indentifier of the tag



53
54
55
# File 'lib/comfortable_mexican_sofa/tag.rb', line 53

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

#is_cms_block?Boolean

Checks if this tag is using Cms::Block

Returns:

  • (Boolean)


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

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

#record_idObject

Used in displaying form elements for Cms::Block



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

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\}/


67
68
69
# File 'lib/comfortable_mexican_sofa/tag.rb', line 67

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.



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

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