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 Comfy::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 Comfy::Cms::Block.
-
#record_id ⇒ Object
Used in displaying form elements for Comfy::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.
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 |
#block ⇒ Object
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 |
#content ⇒ Object
Content that is accociated with Tag instance.
77 78 79 |
# File 'lib/comfortable_mexican_sofa/tag.rb', line 77 def content nil end |
#id ⇒ Object
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
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_id ⇒ Object
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_signature ⇒ Object
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 |
#render ⇒ Object
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 |