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.
-
#identifier ⇒ 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_label/.
-
#render ⇒ Object
Content that is used during page rendering.
-
#snippet ⇒ Object
Find or initialize Cms::Snippet object.
Instance Method Details
#ancestors ⇒ Object
Ancestors of this tag constructed during rendering process.
47 48 49 50 51 |
# File 'lib/comfortable_mexican_sofa/tag.rb', line 47 def ancestors node, nodes = self, [] nodes << node = node.parent while node.parent nodes end |
#block ⇒ Object
Find or initialize Cms::Block object
78 79 80 |
# File 'lib/comfortable_mexican_sofa/tag.rb', line 78 def block page.blocks.detect{|b| b.label == self.label.to_s} || page.blocks.build(:label => self.label.to_s) end |
#content ⇒ Object
Content that is accociated with Tag instance.
61 62 63 |
# File 'lib/comfortable_mexican_sofa/tag.rb', line 61 def content nil end |
#identifier ⇒ Object
String indentifier of the tag
42 43 44 |
# File 'lib/comfortable_mexican_sofa/tag.rb', line 42 def identifier "#{self.class.to_s.demodulize.underscore}_#{self.label}" end |
#is_cms_block? ⇒ Boolean
Checks if this tag is using Cms::Block
88 89 90 |
# File 'lib/comfortable_mexican_sofa/tag.rb', line 88 def is_cms_block? %w(page field).member?(self.class.to_s.demodulize.underscore.split(/_/).first) end |
#record_id ⇒ Object
Used in displaying form elements for Cms::Block
93 94 95 |
# File 'lib/comfortable_mexican_sofa/tag.rb', line 93 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_label\}/
56 57 58 |
# File 'lib/comfortable_mexican_sofa/tag.rb', line 56 def regex_tag_signature self.class.regex_tag_signature(label) end |
#render ⇒ Object
Content that is used during page rendering. Outputting existing content as a default.
67 68 69 70 71 72 73 74 75 |
# File 'lib/comfortable_mexican_sofa/tag.rb', line 67 def render # cleaning content from possible irb stuff. Partial and Helper tags are OK. if !ComfortableMexicanSofa.config.allow_irb && ![ComfortableMexicanSofa::Tag::Partial, ComfortableMexicanSofa::Tag::Helper].member?(self.class) content.to_s.gsub('<%', '<%').gsub('%>', '%>') else content.to_s end end |
#snippet ⇒ Object
Find or initialize Cms::Snippet object
83 84 85 |
# File 'lib/comfortable_mexican_sofa/tag.rb', line 83 def snippet page.site.snippets.detect{|s| s.slug == self.label.to_s} || page.site.snippets.build(:slug => self.label.to_s) end |