Module: ComfortableMexicanSofa::Tag::InstanceMethods
- Defined in:
- lib/comfortable_mexican_sofa/tag.rb
Instance Method Summary collapse
-
#ancestors ⇒ Object
Ancestors of this tag constructed during rendering process.
-
#block ⇒ Object
Find or initialize Cms::Block object.
-
#content ⇒ Object
Content that is accociated with Tag instance.
-
#id ⇒ Object
String indentifier of the tag.
-
#is_cms_block? ⇒ Boolean
Checks if this tag is using Cms::Block.
-
#record_id ⇒ Object
Used in displaying form elements for Cms::Block.
-
#regex_tag_signature ⇒ Object
Regex that is used to identify instance of the tag Example: /<s*?cms:page:tag_identifier/.
-
#render ⇒ Object
Content that is used during page rendering.
Instance Method Details
#ancestors ⇒ Object
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 |
#block ⇒ Object
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 |
#content ⇒ Object
Content that is accociated with Tag instance.
72 73 74 |
# File 'lib/comfortable_mexican_sofa/tag.rb', line 72 def content nil end |
#id ⇒ Object
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
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_id ⇒ Object
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_signature ⇒ Object
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 |
#render ⇒ Object
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 |